-1

MYSQL

create table Emp
( 
 Eid int primary key,
 Ename varcharacter(20) not null,
 Eage int,
 Eadd varcharacter(21) default ' Cairo ',
 HireDate date DEFAULT  ***CURDATE( )***,
 
);

I want to set a default value in the hiring date to be the current date if no date is written in the column but nothing works CURRENT_DATE and CURDATE()

4
  • You have a couple of typos in your code; check the documentation for the correct CREATE TABLE syntax.
    – mustaccio
    Nov 20 at 18:52
  • Sorry, I do not get it .. what is the documentation for the correct CREATE TABLE syntax? Nov 20 at 19:06
  • " ( " is not valid at this Position ... the same error when tying any of those syntaxes (CURDATE()) or (CURRENT_DATE()) or (CURRENT_DATE) Nov 21 at 20:54

1 Answer 1

2

https://dev.mysql.com/doc/refman/8.0/en/create-table.html

Probably just missing parentheses around the expression:

HireDate date DEFAULT (CURDATE( )),
1
  • " ( " is not valid at this Position Nov 21 at 20:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.