Mysql data import and export, data table optimization, mysql Import and Export

Source: Internet
Author: User
Tags mysql import

Mysql data import and export, data table optimization, mysql Import and Export

I. Data Import

Mysqlimport-uroot oa d:/aa.txt -- fields-terminated-by =, -- fields-optionally-enclosed-by = -- lines-terminated-by = \ r \ n

Or

Load data infile 'd:/students.txt 'into table stu fields terminated by '\, 'Lines terminated by' \ N'

Aa indicates the name of the data table to be imported, fields-terminated-by indicates the field separator, and fields-optionally-enclosed-by indicates the delimiters of each field, lines-terminated-by indicates the end mark of a record.

Ii. Data Export

Seect * into outfile 'd:/all.txt 'from students;

Or

Seect * into outfile 'd:/all.csv 'character uft8 fields terminated by', 'Lines terminated by' \ r \ n' from students;

Iii. Optimize and repair tables

With the long-term use of mysql, some problems will certainly occur. For example, if the table cannot be accessed, you can fix the table and reduce disk space usage during optimization.

1. Optimization

Optimize is used to recycle idle database space. When the data rows in the table are deleted, the occupied disk space is not immediately recycled. After the optimize command is used, the space will be recycled, in addition, the data rows on the disk are rearranged (note that they are on the disk rather than the database ). Optimize does not need to be run most of the time. You only need to perform a data table optimization operation once a week or once a month after batch deletion of data rows.

Optimize table table_name1, table_name2

2. Repair the table

Repair table table_name, table_name2

 

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.