-3

Assignment: Insert 4 rows into emp table

Eid, name,  did, hiredate, salary
1,   jeff,  1,   2005-1-1, 70000
2,   susan, 2,   2005-6-1, 50000
3,   bob,   1,   2000-1-1, 90000
4,   steve, 1,   2006-1-1, 60000

My Answer:

INSERT INTO EMP 
VALUES ('1','JEFF','1','2005-01-01',70000);
INSERT INTO EMP
VALUES ('2','SUSAN','2','2005-06-01',50000);
INSERT INTO EMP
VALUES ('3','BOB','1','2000-01-01',90000);
INSERT INTO EMP
VALUES ('4','STEVE','1','2006-01-01',60000);

ERROR:

VALUES ('1','JEFF','1','2005-01-01',70000)
                       *
ERROR at line 2:
ORA-01861: literal does not match format string

VALUES ('2','SUSAN','2','2005-06-01',50000)
                        *
ERROR at line 2:
ORA-01861: literal does not match format string

VALUES ('3','BOB','1','2000-01-01',90000)
                      *
ERROR at line 2:
ORA-01861: literal does not match format string

VALUES ('4','STEVE','1','2006-01-01',60000)
                        *
ERROR at line 2:
ORA-01861: literal does not match format string
Phil Ross
  • 25,590
  • 9
  • 67
  • 77
  • 4
    possible duplicate of [SQL Error: ORA-01861: literal does not match format string 01861](http://stackoverflow.com/questions/22542882/sql-error-ora-01861-literal-does-not-match-format-string-01861) – Phil Ross Aug 29 '15 at 23:57

1 Answers1

0

For a date constant in the format YYYY-MM-DD, use the date indicator:

INSERT INTO EMP 
    VALUES ('1', 'JEFF', '1', DATE '2005-01-01', 70000);

Note: if the first and third columns are numbers, then don't use single quotes.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786