I want a table with the name of an employee and the year of his birth. ONLY THE YEAR IN DATE FORMAT:
CREATE TABLE EMPLOYEE(
Name VARCHAR2(50) NOT NULL,
Year_Birth DATE NOT NULL,
PRIMARY KEY (Name)
);
I want to do this:
INSERT INTO EMPLOYEE(Name, Year_Birth)
VALUES ('John Smith', 1985);
But it doesn't work (cause i'm passing a number value to a date column). I also tried this:
INSERT INTO EMPLOYEE(Name, Year_Birth)
VALUES ('John Smith', to_date('1972','YYYY') )
If i try this one i will get this: ORA-02290: check constraint (PROJECTNAME.SYS_C0066777818) violated
Year_Birth must be a date column. Is there any way to achieve this?
I think birth year should be an INT, like this:
Then this should work: