In my Database i have a table with column
`LastUpdated` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
i would like to Touch a record in that table so that LastUpdated
column will be automatically updated but i don't want to change any value in that row.
Is that possible?
Thank you.
Syntax – Update value to Current Timestamp ALTER TABLE table_name updates table schema. CHANGE column_name updates the column to. column_name TIMESTAMP NOT NULL defines the column as of datatype TIMESTAMP. DEFAULT CURRENT_TIMESTAMP sets the default value of the column to CURRENT_TIMESTAMP.
Here is the SQL you can use to add the column in: ALTER TABLE `table1` ADD `lastUpdated` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ; This adds a column called 'lastUpdated' with a default value of the current date/time.
You can do so by using the SQL UPDATE command. This will modify any field value of any MySQL table.
AFAIK, You don't have options to use touch
to update mysql table records like you touch file in unix
systems. You have to issue an update query to update
the timestamp
in the LastUpdated
column .
UPDATE mytable SET LastUpdated=NOW() WHERE ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With