sql - Adding a column to a table in MySQL database with default value -
i have table named tab1. want add new column table. tried
alter table tab1 add column mod_at timestamp default current_timestamp i succeeded in adding column. default timestamp value added local timestamp. how add utc timestamp default value, instead of local timestamp?
i suspect misunderstand how timestamp column type works. column uses utc internally, converts from/to server/session time zone when read or write. can run query see session's time zone:
select @@session.time_zone now, if change time zone, e.g.:
set @@session.time_zone = '+00:00' ... you'll see values stored change match new time zone. that's expected behaviour.
Comments
Post a Comment