Home >Database >Mysql Tutorial >What is the command to create a table structure in mysql?
In MySQL, the command to create a table structure is CREATE TABLE, and its syntax is: CREATE TABLE table_name (column_name1 data_type1 [constraints], ...);, where table_name is the table name and column_name is the column name. data_type is the column data type and constraints are optional column constraints.
MySQL command to create a table structure
In MySQL, the command to create a table structure is CREATE TABLE
. The syntax format is as follows:
<code class="sql">CREATE TABLE table_name ( column_name1 data_type1 [constraints], column_name2 data_type2 [constraints], ... );</code>
where:
table_name
is the name of the table to be created. column_name
is the column name in the table. data_type
is the data type of the column, such as INT
, VARCHAR
, DATE
, etc. constraints
are optional column constraints, such as NOT NULL
, PRIMARY KEY
, etc. Example
Create a table named customers
with the following columns:
id
: Integer primary key name
: Variable length string type, the maximum length is 255email
: Yes Variable-length string type, allowed to be NULL
using the following CREATE TABLE
command:
<code class="sql">CREATE TABLE customers ( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, email VARCHAR(255) );</code>
The above is the detailed content of What is the command to create a table structure in mysql?. For more information, please follow other related articles on the PHP Chinese website!