Help Center/ GaussDB/ Developer Guide(Centralized_V2.0-8.x)/ FAQ/ How do I create a column whose default value is the current time?
Updated on 2025-05-29 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.

Example:

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