MySQL Create table
MySQL Create table
MySQL Create table syntax and examples.
MySQL Create table syntax
CREATE TABLE table_name (column_name column_data_type) ;
Create an empty table based on the definition of another table
CREATE TABLE new_table_name LIKE parent_table_name;
Create a table using select statement from another table
CREATE TABLE new_table_name SELECT * FROM parent_table_name;
Create table example
CREATE TABLE `products` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(500) NOT NULL, `description` varchar(4000) NOT NULL, `price` double NOT NULL, CONSTRAINT PRIMARY KEY (`id`) ) ;
Output
table `products` created.
Clone or copy table example
CREATE TABLE test2 LIKE test;
Output
table TEST2 created.
Create a table using select statement
CREATE TABLE test3 SELECT * FROM test;
Output
table TEST3 created.