How to set default value for sysdate in MySql?

I am going to create a table with a column that stores a Created_date file that has a datetime data type. And my goal is to set the default as sysdate ().

I tried

CREATE TABLE tbl_table(    created_datedatetime DEFAULT sysdate ())

This gives me an error saying that this is not a valid default instruction. I used the same logic in Oracle. Please help me solve this problem.

Thanks in advance.

+5
source share
1 answer

Try CREATE TABLE tbl_table ( created_date TIMESTAMP DEFAULT NOW())

But: NOWdifferent from sysdateand TIMESTAMPdifferent from datetime, remember this.

. TIMESTAMP - , ​​, NOW(). . MySQL Bugtracker.

+12

All Articles