For e.g. I have a table named people with the following columns-
people_id (primary key, auto inc)
first_name
last_name
timestamp (default - current_timestamp)
This table already had 30,000 rows before the last column timestamp was added, so at present all the timestamps are the same. I want each timestamp to be unique, but I am unable to do so.
Closest answer on stackoverflow I could found, is of Oracle, which suggests the following query -
UPDATE ITEM_HISTORY SET my_timestamp = SYSTIMESTAMP + NUMTODSINTERVAL(rownum/1000, 'SECOND');
But this query does not work in MySQL, because there are no such functions for NUMTODSINTERVAL and SYSTIMESTAMP. I tried to use above mentioned query as -
UPDATE people SET `timestamp` = CURRENT_TIMESTAMP + people_id;
But it failed, I think because, people_id (int) can't be added to timestamp. So is there any way to convert and add the people_id in timestamp or any other way to update rows with unique timestamps?
Thanks.
UPDATE people SET `timestamp` = CURRENT_TIMESTAMP + INTERVAL people_id MINUTE;