简体   繁体   中英

SQL: Insert DateCreated value?

In my table I have a dateCreated column in the format of DATETIME.

How do I insert the current datetime when I add the record to the database?

Better use TIMESTAMP instead and use CURRENT_TIMESTAMP to get current timestamp. TIMESTAMP should behave exaclty (or very similar) to DATETIME so you shouldn't notice a difference.

Furthermore you may set CURRENT_TIMESTAMP as default for all new entries.

使用CURDATETIME()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM