====== CSVのインポート ====== [[database:mysql|一つ上へ]] クライアント、サーバー共に''local_infile''パラメータを有効にしておく必要がある。 set global local_infile=on; ''import.csv'' ファイルをtest_dbのtest_tbテーブルにインポートする場合、以下のコマンドを実行する。 load data local infile '/path/to/import.csv' into table test_db.test_tb fields terminated by ',' enclosed by '"' ; ^オプション^説明及びクエリ^ |into table|通常通りインポート| |replace into table|主キーに重複がある場合に置き換える| |ignore into table|主キーに重複があり、それを無視する場合| ^オプション^説明及びクエリ^ |terminated by|区切り文字を指定。デフォルトでは'\t'なのでカンマ区切りの場合は','を指定する。| |escaped by|エスケープ文字の指定。デフォルトでは'\\'| |enclosed by|文字列を囲み文字の指定。| 既存のテーブルを置き換えるには、''replace into table''とする。