How to solve the problem of table structure replication in MySQL

Source: Internet
Author: User
Tags mysql command line

The method for copying the table structure in MySQL is a topic we often discuss. We have analyzed the structure of the MySQL replication table for your reference. We hope that you will have a deeper understanding of the structure of the MySQL replication table.

I saw a lot of usage on the Internet.

SELECT * INTO Table 2 FROM table 1 WHERE 1 = 2

You can copy the table 1 structure to table 2.

Use SELECT * INTO Table 2 FROM table 1

You can copy all contents of Table 1 to table 2.

But an error is reported every time: Table 2 is not declared.

Table 2 is created in advance. It is still said that table 2 is not declared.

Bytes ----------------------------------------------------------------------------------------------------

Final Solution: Do not use

First, go to the MySQL command line:

Use database_name;

Create table table_name select * from original_table_name where 1 = 2;

In this way, a new table is generated, and its table structure is the same as that of the original table, but there is no data in the original table.

If you want to copy the data together, you can input:

Create table table_name select * from original_table_name where 1 = 1;

In this way, the two tables are identical.

You can modify the red font as needed)

Create a table in Mysql

MySQL connection query Overview

MySQL sorting usage

View the processes of the MySQL server

Mysql Key_buffer_size parameter settings

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.