In the previous article to introduce the MySQL use of a simple tutorial (ii)
Two tables with the same structure in MySQL are merged: (Note that two tables are required for the same structure)
There are two table father and person with the following structure.
The steps for merging are:
1. The person table and the Father table two tables are jointly exported to temporary table tmp.
command is : >create temporary table tmp SELECT * FROM person Union select *from Father;
2. Create a result table and create a primary key.
The command is : >create table ResU (name varchar () primary key,age Int,high int,address);
3. Filter the data in the temporary table and write to ResU.
The command is : >insert into ResU (name,age,high,address) SELECT distinct name,age,high,address from TMP;
4. Delete temporary table tmp.
The command is : >drop table tmp;
Think: ① can only use one of the following commands : >create table tmp SELECT * FROM man Union select *from Father; To create a new table?
② all two tables are from the same database, then how about two tables from different databases merge?
③ above is a two-table combination of up and down, then about the merger?
There are many ways to do MySQL database backup, where you can choose to use command parameter backups.
It should be noted that the database backup needs to be done under the system command line, not under the MySQL command.
1. Export the entire database.
Command: $mysqldump-u user name-p password database name > exported file name
Note: A. Passwords can be entered in an invisible form in the second line, which is the safest.
B. The exported file needs to be established by itself, preferably at the end of the. sql format.
2. Export a table.
Command: $mysqldump-u user name-p password database name table name > exported file name
As seen from above, exporting a table is much the same as exporting a database.
The above is a small set of MySQL to introduce you to use a simple tutorial (iii) Related knowledge, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!