0

SQL:

CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20),
    species VARCHAR(20), sex CHAR(1), joindate DATE default now(), death DATE)  

Error:

Error Code: 1067. Invalid default value for 'joindate' 0.000 sec

JNevill
  • 46,980
  • 4
  • 38
  • 63
Sun
  • 3,444
  • 7
  • 53
  • 83
  • 1
    use `CURRENT_TIMESTAMP` as default after changing the data type to `timestamp` – Pathik Vejani Dec 11 '15 at 13:05
  • Check this answer on [SO](http://stackoverflow.com/questions/20461030/current-date-curdate-not-working-as-default-date-value), like @hnn said.... – Walucas Dec 11 '15 at 13:12
  • I am closing this as a duplicate. However, it is important to understand that `date` and `datetime` can have such defaults in MySQL 5.6+. – Gordon Linoff Dec 11 '15 at 13:14
  • So, Could you please provide alternative ways to achieve. ie. I have to have join_data with default value is current date in mysql5.5. I am not perticular to Date data type. even date and time combination also no issue. – Sun Dec 12 '15 at 11:40

0 Answers0