“Convert sql to csv”版本间的差异

来自cslt Wiki
跳转至: 导航搜索
(以“1. create database and load sql to it. a) create database <database_name> b) use <database_name> c) source <xxx.sql> 2. obtain the column names and save csv. a)...”为内容创建页面)
 
(没有差异)

2018年2月3日 (六) 11:41的最后版本

1. create database and load sql to it.

a) create database <database_name>
b) use <database_name>
c) source <xxx.sql>

2. obtain the column names and save csv.

a) select group_concat(concat("'",column_name,"'")) from information_schema.columns where table_name = '<table_name>';
b) select <column_string>
   union all 
   select * from <table_name> into outfile '/var/lib/mysql-files/xxx.csv' 
   fields terminated by ',' 
   optionally enclosed by '"' escaped by '\\' 
   lines terminated by '\n';

3. replace \N with in csv.

a) sed -i 's/\\N//g' xxx.csv