Mysql using a simple tutorial (iii) _mysql

Source: Internet
Author: User

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!

Related Article

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.