I've a table which has a column defined like this:
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------+------+-----+-------------------+----------------+
| created_at | timestamp | NO | | CURRENT_TIMESTAMP | |
and I insert data using this command:
LOAD DATA LOCAL INFILE '<path_to_the_file>' INTO TABLE my_table FIELDS TERMINATED BY '|' (<some_columns>,created_at,<more_columns>)
from a file where each line is like this:
822202|NETGEAR|||||1448ce8f-efc5-7b07-6982-1ff991bf967e||||||||1|||
Note: created_at is the 5th column, so the file has no value for it, therefore I expect CURRENT_TIMESTAMP
instead, this is what I see:
mysql> select distinct created_at from my_table;
+---------------------+
| created_at |
+---------------------+
| 0000-00-00 00:00:00 |
+---------------------+
1 row in set (0.00 sec)
the code running the command is, supposedly, using a standard JDBC, it's a jdbc.clj Clojure library.
Note 2: if I run INSERT INTO ... query manually, it (obviously) works as expected.
Anyone can tell me what am I missing?
TIMESTAMP columns are set to the current date and time only if there is a NULL value for the column (that is, \N) and the column is not declared to permit NULL values, or if the TIMESTAMP column's default value is the current timestamp and it is omitted from the field list when a field list is specified.- 13.2.6 LOAD DATA INFILE Syntax.