MySQL table copy and backup restore

Source: Internet
Author: User

1. Duplicate table structure1.1 Complete table structure with information such as primary keyCREATE table New table name like book;1.2 Only table structure, no primary key and other informationCREATE table new table name select * from books;orCREATE table new table name as (SELECT * from book);orCREATE table new table name select * from books where 1=2;2. Pour data from old tables into new table insert into new table SELECT * from old table; Note: The new table must already exist 3. Enter the DDL statement that created the table the name of the Show create table table; 4. Empty the table data truncate the table name; 5. Backing up a database such as backing up the library database go to the bin directory of MySQL C:\Program files\mysql\mysql Server 5.5\bin> Take advantage of "mysqldump-u username-P database name > Backup Name" Export database to file C:\Program files\mysql\mysql Server 5.5\bin>mysqldump-u root-p Library >library.sqlenter Password: * * * . 6. Restore Database Restore library database as an example, create database library and then enter "source path" under Mysql>.

MySQL table copy and backup restore

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.