How to copy a data table in a MySQL database

Source: Internet
Author: User
Copy the table in MySQL and copy the old_table table to the new_table table. 1. Do not copy table data, just copy structure. CREATETABLEnew_tableLIKEold_table2. copy the data using the SELECT query. The new_table table will lose the primary key, index, and other information. Reference CREATETABLEnew_tableAS (SELECT * FROMold _

Copy the table in MySQL and copy the old_table table to the new_table table. 1. Do not copy table data, just copy structure. Create table new_table LIKE old_table 2. Copy data through SELECT queries. new_table tables will lose information such as primary keys and indexes. Reference create table new_table AS (SELECT * FROM old _

Copy the table in MySQL and copy the old_table table to the new_table table.

1. Do not copy table data, just copy structure.

Create table new_table LIKE old_table

2. Copy data using the SELECT query. The new_table table will lose information such as the primary key and index.

Reference

Create table new_table

(

SELECT *

FROM old_table

)

3. Completely copy the table

Create table new_table LIKE old_table;

Insert into new_table SELECT * FROM old_table;

4. Copy fields only

Create table new_table

(

SELECT field1, field2 FROM old_table

)

5. Partial copy

Create table new_table

(

SELECT * FROM old_table WHERE field1 = 'mangguo'

)

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.