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, use CREATE TABLE
command to create basic tables.
Syntax:
<code>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] );</code>
Parameters:
Example:
Create a table named customers
with customer_id
(primary key), first_name
, last_name
and email
columns:
<code class="sql">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 );</code>
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!