I have the following file(this is just 1 column of a file I am trying to import. I figure if I get this 1 column right, I can then do the other columns):
$ cat head_test_1col.csv
"Rec Open Date"
"2015-10-06"
"2015-10-06"
"2015-10-06"
"2015-10-06"
"2015-10-06"
"2015-10-06"
"2015-10-06"
"2015-10-06"
"2015-10-06"
now i can create my table in mysql as follows:
CREATE TABLE IF NOT EXISTS test1234 (
id int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
`Rec Open Date` Date NOT NULL COMMENT 'Rec Open Date',
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='datatable demo table' AUTO_INCREMENT=64 ;
Then I try and add the rows with either of the following, 1 or 2, but it is not populating correctly.
1
LOAD DATA LOCAL INFILE 'head_test_1col.csv' INTO TABLE test1234 COLUMNS TERMINATED BY ',';
2
LOAD DATA LOCAL INFILE 'head_test_1col.csv' INTO TABLE test1234
I get the following(just all zeros):
mysql> LOAD DATA LOCAL INFILE 'head_test_1col.csv' INTO TABLE test1234;
Query OK, 10 rows affected, 20 warnings (0.00 sec)
Records: 10 Deleted: 0 Skipped: 0 Warnings: 20
mysql>
mysql>
mysql> select * from test1234;
+----+---------------+
| id | Rec Open Date |
+----+---------------+
| 64 | 0000-00-00 |
| 65 | 0000-00-00 |
| 66 | 0000-00-00 |
| 67 | 0000-00-00 |
| 68 | 0000-00-00 |
| 69 | 0000-00-00 |
| 70 | 0000-00-00 |
| 71 | 0000-00-00 |
| 72 | 0000-00-00 |
| 73 | 0000-00-00 |
+----+---------------+
10 rows in set (0.00 sec)
mysql>
Can anyone advise how I can get the data to populate correctly?