Domanda

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.

È stato utile?

Soluzione

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);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top