Analysis of the difference between create table as and like in Mysql _mysql

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.