The command to create a basic table in SQL is CREATE TABLE. It is used to create a basic table with column names, data types and constraints like NOT NULL, DEFAULT.
Commands to create basic tables in SQL
In SQL, useCREATE TABLE
command to create basic tables.
Syntax:
CREATE TABLE table_name ( column_name1 data_type [NOT NULL | NULL] [DEFAULT default_value], column_name2 data_type [NOT NULL | NULL] [DEFAULT default_value], ... column_nameN data_type [NOT NULL | NULL] [DEFAULT default_value] );
Parameters:
Example:
Create a table namedcustomers
withcustomer_id
(primary key),first_name
,last_name
andemail
columns:
CREATE TABLE customers ( customer_id INT NOT NULL AUTO_INCREMENT, first_name VARCHAR(50) NOT NULL, last_name VARCHAR(50) NOT NULL, email VARCHAR(100) UNIQUE NOT NULL );
Note:
PRIMARY KEY
constraints.UNIQUE
constraints.AUTO_INCREMENT
keyword.The above is the detailed content of What command is used to create a basic table in sql. For more information, please follow other related articles on the PHP Chinese website!