MySQLへCSVのインポート

これも忘れてた。

C:\Aptana IDE Beta\iftb>mysql -u root -p
Enter password: *******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 41
Server version: 5.0.41-community-nt MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> connect iftb_development
Connection id: 42
Current database: iftb_development

んでインポートする(Vistaの上で動いているMySQL5ね)

mysql> load data infile "C:\\Users\\username\\Documents\\convert.csv" into table
iftbs fields terminated by ',' enclosed by '"' lines terminated by '\r\n';
ERROR 1292 (22007): Incorrect datetime value: '2006 12/1 09:00' for column 'dtst
art' at row 1

データ型が異なるらしい。
 
こちらを参考にする

http://powerdee.com/it/mysql/dataTypes.html
SQL関数STR_TO_DATEを使用しない限り、「YYYY-MM-DD 24HH:MI:SS」または「YYYYMMDD24HHMISS」というフォーマットでなければならない。
(YYYY:年4桁、MM:月、DD:日、24HH:24時間制の時、MI:分、SS:秒)
違反した場合は、「0000-00-00 00:00:00」のようにゼロが格納される。

csvファイルはエクセルで加工しているので、関数で対処する

=CONCATENATE(TEXT(J3,"yyyy/mm/dd")," ",TEXT(H3,"hh:mm:ss"))

こんどは違うエラーになる。

mysql> load data infile "C:\\Users\\username\\Documents\\convert.csv" into table
iftbs fields terminated by ',' enclosed by '"' lines terminated by '\r\n';
ERROR 1366 (HY000): Incorrect string value: '\x90VIFB' for column 'machine' at r
ow 1