timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP

I have a timestamp in mysql table to record the timestamp of the update (insert/update etc.)

But if the data is not added by "insert" but the data is added through "load data local infile", the timestamp would stay to be "01/01/0001 12:00:00 am".

Any advices?

Thanks!

    first idea that comes to mind

    update table set timestamp=NOW() WHERE timestamp="01/01/0001 12:00:00 am"

    check that that's the right timestamap value to match (defult is 0000-00-00 00:00:00) and you may have something else yo could match on.

      6 days later

      Is there a way to have a DEFAULT in the import file? In pg you'd do something like:

      1,'text',DEFAULT

      in the input file. I don't know about mysql tho.

        this should work,LOAD DATA INFILE 'file.txt'

        INTO TABLE t1
        (column1, column2)
        SET column3 = CURRENT_TIMESTAMP;

        as the post is a week old, hes probably solved it by now

          Write a Reply...