Link: http://blog.csdn.net/kongxx/article/details/7051439
MySQL provides a tool for importing and exporting databases. However, sometimes we only need to import and export data from a single table, such as importing and exporting CSV files. In this case, you can use the MySQL Automatic Command to import and export data.
The export syntax is as follows:
Select * from [Table] <br/> into OUTFILE '[file]'; <br/> or <br/> select * from [Table] <br/> into OUTFILE '[file]' <br/> fields terminated ', '<br/> optionally enclosed by' "'<br/> lines terminated by' \ n ';Below is a specific example of export:
Select * From mytable <br/> into OUTFILE '/tmp/mytable.csv' <br/> fields terminated ', '<br/> optionally enclosed by' "'<br/> lines terminated by' \ n ';
The import syntax is as follows:
load data infile '[file]' <br/> into table [Table]; <br/> or <br/> load data infile '[file]' <br/> into table [Table] <br/> fields terminated ', '<br/> optionally enclosed by' "'<br/> lines terminated by' \ n'; The following is an example of a specific import:
load data infile '/tmp/mytable.csv' <br/> into Table mytable <br/> fields terminated ', '<br/> optionally enclosed by' "'<br/> lines terminated by' \ n';