1. The syntax for creating a data table in mysql
CREATE TABLE table_name (column_name column_type);
It is very easy to create a MySQL table at the mysql> prompt. Use the SQL command CREATE TABLE
to create a table.
Before creating the table, you need to use the use databasename
command to select the database.
2. Create mysql data table
Example:
root@host# mysql -u root -p Enter password: mysql> use TUTORIALS; Database changed mysql> CREATE TABLE tutorials_tbl( -> tutorial_id INT NOT NULL AUTO_INCREMENT, -> tutorial_title VARCHAR(100) NOT NULL, -> tutorial_author VARCHAR(40) NOT NULL, -> submission_date DATE, -> PRIMARY KEY ( tutorial_id ) -> ); Query OK, 0 rows affected (0.16 sec) mysql>
The above is the detailed content of How to create a table in mysql. For more information, please follow other related articles on the PHP Chinese website!