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