mysql导入导出csv文件

时间:2022-04-02 10:04:17

mysql导出csv文件

语法块

`select block`
into outfile `/path/of/file`
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\r\n';

例子

select * from test_info
into outfile '/tmp/test.csv'
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\r\n';

mysql导入csv文件

语法块

load data infile '/path/of/file'
into table `/name/of/table`
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\r\n';

例子

load data infile '/tmp/test.csv'
into table test_info
fields terminated by ',' optionally enclosed by '"' escaped by '"'
lines terminated by '\r\n';