1

I've created the following table:

CREATE TABLE match(
match_id NUMBER(4,0), 
match_date DATE, 
attendance NUMBER(6,0), 
stadium_name VARCHAR2(40), 
tournament_id NUMBER(3,0),
CONSTRAINT match_id_pk PRIMARY KEY(match_id),
CONSTRAINT match_stadium_name_fk FOREIGN KEY(stadium_name) 
           REFERENCES stadium(stadium_name));

I attempt to insert the following line:

INSERT INTO match VALUES(1001, '20130515', 90000, 'American Airlines Arena', 001);

Everything I've found tells me the format is YYYYMMDD. However I keep getting ORA-01861: literal does not match format string.

After using (DESCRIBE match) it says the length is only 7. I thought it was supposed to be 10.

Thanks in advance for any help.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
William Roeser
  • 67
  • 1
  • 2
  • 4

1 Answers1

7

Well, the format YYYYMMDD is probably not the database date format (you should look for NLS_DATE_FORMAT to see what's the db date format).

But there's a NLS_DATE_FORMAT at the system level and a (maybe other) NLS_DATE_FORMAT at the session level.

You can achieve what you want using TO_DATE and specifying the format :

INSERT INTO match VALUES(1001, TO_DATE('20130515', 'YYYYMMDD'), 90000, 'American Airlines Arena', 001);
Raphaël Althaus
  • 59,727
  • 6
  • 96
  • 122
  • Great! thank you very much. My text only seems to mention about querying with the TO_DATE I didn't know you could use it in an insert. – William Roeser Oct 04 '13 at 13:17