I have the following table and sql commands. The number of fields in
the file is different from that of the schema. And the last line
should not contain null. But there are only warnings but not errors
generated. I'm wondering how to generate errors instead of warnings.
~/linux/test/mysql/mysql/LOAD_DATA/csv$ cat table.csv
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 45
Server version: 5.5.9 Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SET sql_mode = 'STRICT_TRANS_TABLES';
Query OK, 0 rows affected (0.00 sec)
mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
mysql> CREATE TEMPORARY TABLE test (
-> id INTEGER
-> , name VARCHAR(3) NOT NULL
Query OK, 0 rows affected (0.02 sec)
mysql> load data local infile 'table.csv' into table test FIELDS
TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'; -- ESCAPED BY '"';
Query OK, 5 rows affected, 7 warnings (0.03 sec)
Records: 5 Deleted: 0 Skipped: 0 Warnings: 7
|• Generate errors when loading table||Peng Yu||16 Oct|