Mysql time related learning notes. timestamp vs datetime range the TIMESTAMP type’s range is ‘1970-01-01 00:00:01’ UTC to ‘2038-01-09 03:14:07’ UTC. the DATETIME type’s range is ‘1000-01-01 00:00:00’ to ‘9999-12-31 23:59:59’. why I can set timestamp a invalid default value That is because of server SQL Mode - NO_ZERO_DATE. From the reference: NO_ZERO_DATE - In strict mode, don’t allow ‘0000-00-00’ as a valid date. You can still insert zero dates with the IGNORE option. When not in strict mode, the date is accepted but a warning is generated. how to init timestamp and datatime CREATE TABLE t1 ( ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP , dt DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ); Mysql lock Alter table and lock alter table without locking table? create a new table and copy content to it, finally rename table for mysql online operation is not good enough to handle all DML operations ...
Learn programming, still on the way