import TabItem from "@theme/TabItem"; import Tabs from "@theme/Tabs";
CREATE A TABLE
After we've constructed the database, we may add tables to it. Tables can only be created by the database owner or other accounts having access permissions to the database. To build a table, we can use the CREATE TABLE
statement. To store our book information, we can use the following SQL command to create a book
table in the bookshop
database.
SQL Example
CREATE TABLE bookshop.book (
id INT(11) PRIMARY KEY COMMENT 'id',
name VARCHAR(255) COMMENT 'name of book',
category VARCHAR(255) COMMENT 'book category (eg:history,cartoon..)',
author VARCHAR(255) COMMENT 'author',
public_at INT(11) COMMENT 'public time',
stock INT(11) COMMENT 'stock of book',
price INT(11) COMMENT 'price',
_tx_id VARCHAR(255),
KEY `name_ind` (name),
KEY `name_author_ind` (name, author)
) ENGINE=standard;