mysqlのcsv入出力
備忘録。まんまここの内容。
http://blog.dacelo.info/mysql/entry-41.html
csvへ出力:
select * from database into outfile "/tmp/dump.csv" fields terminated by ',';
csvへ入力:
load data local infile "/tmp/dump.csv" into table tablename fields terminated by ',';
要素を囲いたい場合:
enclosed by '"'
改行コードを指定したい場合:
lines terminated by '\r\n'
関係ないけどテーブルのステータス:
show table status like 'テーブル' ←like句なのでシングルクォートも必要
auto_incrementの変更:
alter table テーブル auto_increment 数字