all records have same TIMESTAMP value. i am not setting any value for updated_at column in the load data infile statement. Why such behaviour
Expecting the seconds to be different as it is not possible to insert 5 million records within 1 s.
2023-05-07 06:26:36 example. at least the seconds should be different for some records
mysql -h$1 -u$2 -p$3 --local-infile=1 -e "LOAD DATA LOCAL INFILE '$4' INTO TABLE abc FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' ESCAPED BY '\"' LINES TERMINATED BY '\n' IGNORE 1 LINES ( legal_name, pg_merchant_id, ip_addr)"
table structure :
CREATE TABLE `abc` (
`pg_merchant_id` varchar(10) NOT NULL,
`legal_name` varchar(100) NOT NULL,
`ip_addr` varchar(150) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `updated_at_idx` (`updated_at`)
)
CURRENT_TIMESTAMPwill be the time the LOAD statement began. This is stated in the docs:https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_current-timestamp :
https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_now :
I suggest you set updated_at after the load finishes; if you do the load file and update in a transaction, they won't see the earlier values.
Even then, the other team needs to know the longest any statement or transaction can take, and look for updated_at at least that far in the past. If they are just comparing to the current time, they will miss some updates or inserts.