DEV Community

pooyaalamdari
pooyaalamdari

Posted on

create table SQL

Certainly! Let's take a practical example of a database for a bookstore. We'll create a table to store information about books. Here's how the SQL code might look:

CREATE TABLE Books (
    BookID INT,
    Title VARCHAR(100),
    Author VARCHAR(100),
    ISBN VARCHAR(13),
    Price DECIMAL(5,2),
    InStock BOOLEAN
);
Enter fullscreen mode Exit fullscreen mode

In this Books table:

  • BookID is an integer that uniquely identifies each book.
  • Title is a variable character string that can store book titles up to 100 characters.
  • Author is a variable character string for the name of the author, also up to 100 characters.
  • ISBN is the International Standard Book Number, a unique code for books.
  • Price is a decimal value that represents the cost of the book, with two digits after the decimal point.
  • InStock is a boolean value indicating whether the book is currently in stock (true or false).

This table structure allows the bookstore to keep track of their inventory and book details efficiently.

Top comments (0)