This paper analyzes the difference between create table as and like in MySQL. Share to everyone for your reference, specific as follows:
For MySQL copy the same table structure method, there are create table as and create table like two kinds, what is the difference?
Copy Code code as follows:
CREATE TABLE t2 as SELECT * from T1 where 1=2;
Or
Copy Code code as follows:
Limit 0;
The T2 table (new table) as created is missing the index information for the T1 table (the source table), with the same table structure and no indexes.
Copy Code code as follows:
CREATE table t2 like T1;
Like the new table created contains the full table structure and index information of the source table
Use of the two:
As used to create the same table structure and copy the source table data
Like to create a full table structure and all indexes
Oracle supports as, and only table structure is not indexed
Oracle does not support like.
I hope this article describes the design of MySQL database to help.