Home >Database >Mysql Tutorial >What is the command to create a database table in mysql?
In MySQL, use the CREATE TABLE table_name (column_name data_type [column_constraint], ...) command to create a database table, which contains the table name, column name, data type, and optional column constraints.
In MySQL, the command to create a database table is:
<code class="sql">CREATE TABLE table_name ( column_name1 data_type [column_constraint], column_name2 data_type [column_constraint], ... );</code>
Create a table named users
containing id
, name
and email
Three columns:
<code class="sql">CREATE TABLE users ( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, email VARCHAR(255) UNIQUE );</code>
Description: The
id
column is an integer, non-empty and automatically incremented. name
column is a variable length string, up to 255 characters, non-empty. The email
column is a variable-length string, up to 255 characters, that is unique. The above is the detailed content of What is the command to create a database table in mysql?. For more information, please follow other related articles on the PHP Chinese website!