Now there is a table named student. I want to copy the data in this table to a new table named dust. Although the following statements can be used for copying, I always feel uncomfortable, thank you for your help.
Answer 01:
Create Table Dust select * from student; // when no new table dust is created before Replication
Answer 02:
Insert into dust select * from student; // when a new table dust has been created
Please use the Select... into... statement to implement the above. Thank you for your support. Thank you again!
User reply: The reply was deleted by the Moderator at 06:37:03
The user replied: sqlserver can perform that sort, but MySQL does not seem to work. In addition, the two sort methods you mentioned should be the most common.
User reply: Create Table Dust select * from student;
The user replied: I wrote it in my post upstairs. What I want is the select into statement?
Thank you for your help!
User reply: MySQL does not support the select into statement to directly back up the table structure and data. Some methods can be used instead, or other methods can be processed. The summary is as follows:
Method 1:
MySQL does not support:
Select * into new_table_name from old_table_name;
Alternative method:
Create Table new_table_name (select * From old_table_name );
Method 2:
1. Back up the table structure and data first.
# Export command-u user name-P password-H Host IP Address Database Name table name 1> export file. SQL
Mysqldump-uroot-proot-h192.168.0.88 OK _db oktable2> OK _db. SQL
2. Modify the name of the backup table
3. log on to MySQL
4. Select a database
5. Run the following command: Source backup table path: source D:/OK _db. SQL, and press Enter.
6. Complete.
MySQL select into OUTFILE is used to export the specified data to the file:
1.export all data in the table to the cdisk root directory outfile.txt as follows:
Select * into OUTFILE 'C: // outfile.txt 'from test;
2. In the export table, specify the data with the query Condition No. 2005-06-08to the cdisk root directory outfile1.txt as follows:
Select * into OUTFILE 'C: // outfile.txt 'from test where begindate = '2017-06-08 ';
Mysql> load data local infile "D:/gpsdata.txt" into Table positiondata fields terminated by ';' (userid, latitude, longpolling, altitude, speed, innerid, Repo
Rttime, status );
Load data [low_priority concurrent] [local] infile 'file_name.txt'
[Replace ignore]
Into Table tbl_name
[Fields
[Terminated by 'string']
[[Optionally] enclosed by 'Char ']
[Escaped by 'Char ']
]
[Lines
[Starting by 'string']
[Terminated by 'string']
]
[Ignore number lines]
[(Col_name_or_user_var,...)]
[Set col_name = expr,...)]
Fields and lines are at the front, (col_name_or_user_var ,...) If you put the attributes you want to write directly after the table name when using it, this is incorrect and must be written after fields and lines!
User reply: reference the reply of wufongming on the 5th floor:
MySQL does not support the select into statement to directly back up the table structure and data. Some methods can be used instead, or other methods can be processed. The following is a summary:
Method 1:
MySQL does not support:
Select * into new_table_name from old_table_name;
Alternative method:
Create Table new_table_name (select * From old_table_name );
Method 2:
1. Back up the table structure and data first.
# Export command-u user name-P password-H Host IP Address Database Name table name 1> export file. SQL
Mysqldump-uroot-proot-h192.168.0.88 OK _db OKT...
Friends on the fifth floor explained the above questions about the select into statement in MySQL. MySQL does not support the select into statement to directly back up the table structure and data.
I think method 1 is much more flexible than method 2, because the solution raised by a friend upstairs is to create a new table, and the field name and structure of the table are the same as those of the original table, if a new table has been created, but there is no data in the table, and the field name of the new table is different from the original table but the type is the same, the second method is not applicable.
So I think the method is a little better and there is room for modification, but it is not easy for a friend on the fifth floor to say this well!
You can choose one based on your needs!
User reply: By the way, it is a good choice to use the select into statement in the SQL Server database to copy table data!
User reply: Gains!
Thanks!
User reply: reference the reply of wufongming on the 5th floor:
MySQL does not support the select into statement to directly back up the table structure and data. Some methods can be used instead, or other methods can be processed. The following is a summary:
Method 1:
MySQL does not support:
Select * into new_table_name from old_table_name;
Alternative method:
Create Table new_table_name (select * From old_table_name );
Method 2:
1. Back up the table structure and data first.
# Export command-u user name-P password-H Host IP Address Database Name table name 1> export file. SQL
Mysqldump-u...
In addition, table A cannot have an auto-increment ID when copying data to table B.
If auto-increment IDs exist, auto-increment IDs are not inserted.
Insert into B (title) Select title from