Search code examples
mysql

mysql throwing syntax error for curdate() function


i am trying to create a sample table like this:

create table dummy (bb varchar(10),gg datetime DEFAULT CURDATE());

am i not supposed to use curdate function while table creation??


Solution

  • You cannot use CURDATE() as a default value. Try this instead:

    CREATE TABLE dummy
    (
        bb varchar(10),gg TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    );