I want a timestamp field in MySQL table, to be set only on inserts, not on updates. The table created like that:
CREATE TABLE `test_insert_timestamp` (
`key` integer NOT NULL,
`value` integer NOT NULL,
`insert_timestamp` timestamp DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`key`)
);
The data is loaded with this sentence (need to be used LOAD DATA LOCAL INFILE):
LOAD DATA LOCAL INFILE
"inserts_test_timestamp1.txt"
REPLACE
INTO TABLE
`test_insert_timestamp`
FIELDS TERMINATED BY ';'
Note: I need to use REPLACE option, not matter why.
The content of inserts_test_timestamp**1**.txt
been:
1;2
3;4
I have another file inserts_test_timestamp**2**.txt
been:
3;4
5;6
What I wont is:
if I load file
inserts_test_timestamp**1**.txt
then the fieldinsert_timestamp
is set (that is ok with the code)if I load
inserts_test_timestamp**2**.txt
, record (3;4) don't change fieldinsert_timestamp
already set, but record (5;6) set newinsert_timestamp
.
But no way. Both records are timestamped with same value, instead of left (3;4) with the old timestamp.
I'm working on MariaDB 5.5.52
database over CentOS 7.3
release. Think that MariaDB
version is important, but I can't change that.