Help Center/ GaussDB/ Developer Guide(Centralized_8.x)/ FAQ/ How do I create a column whose default value is the current time?
Updated on 2024-06-03 GMT+08:00

How do I create a column whose default value is the current time?

Answer: When creating a table, set the default value of the column to CURRENT_TIMESTAMP.

gaussdb=#CREATE TABLE tbl (id int, modtime date DEFAULT CURRENT_TIMESTAMP);