Use CREATE TABLE syntax to create a MySQL table. You need to specify the table name, column name, data type, whether to allow null values and default values. Among them, the table name and column name are case-sensitive, the primary key column must be non-null, and the default value should comply with the data type constraints.
MySQL table creation syntax
The syntax for creating a table in MySQL is as follows:
<code>CREATE TABLE table_name ( column_name1 data_type1 [NOT NULL] [DEFAULT default_value1], column_name2 data_type2 [NOT NULL] [DEFAULT default_value2], ... ) [table_options];</code>
Detailed explanation of syntax:
Example:
Create a table named "employees", which contains three columns: "id" (primary key), "name" ( String) and "salary" (number):
<code class="mysql">CREATE TABLE employees ( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, salary DECIMAL(10, 2) NOT NULL );</code>
Note:
The above is the detailed content of What is the syntax for creating tables in mysql database. For more information, please follow other related articles on the PHP Chinese website!