Reputation: 11
(songs table)
insert into albums values('Queen', 'Keep Yourself Alive','Brian','1973')
insert into albums values('Queen', 'Liar', 'Freddie','1973')
insert into albums values('Queen II', 'The Fairy Fellers Master Stroke', 'Freddie','1974')
insert into albums values('Queen II', 'Funny How Love Is', 'Freddie', '1974')
insert into albums values('A Night At The Opera', 'Youre My Best Friend', 'John', '1975')
insert into albums values('Jazz', 'Dead On Time', 'Brian', '1978')
insert into albums values('The Game', 'Another One Bites The Dust', 'John', '1980');
create table albums(
album_title varchar2(50),
song_title varchar2(50),
band_member varchar2(30),
year int(4));
I keep on getting this error
SQL> @songs;
insert into albums values('The Game', 'Another One Bites The Dust', 'John', '1980')
*
ERROR at line 1:
ORA-01861: literal does not match format string
What is wrong with my commands?
Upvotes: 1
Views: 379
Reputation: 864
With Oracle characters between single quote marks are STRINGS, try removing it to the year field or using the function TO_NUMBER()
Examples:
insert into albums values('The Game', 'Another One Bites The Dust', 'John', 1980)
or
insert into albums values('The Game', 'Another One Bites The Dust', 'John', TO_NUMBER('1980'))
Edit:
(Answer from comments below)
You need to change the datatype of the column year, try this:
alter table albums modify( year number(4) ) ;
Upvotes: 1
Reputation: 17643
If you define your table with year number(4)
, and put ;
after every insert, everything should work fine.
Upvotes: 0
Reputation: 12557
I didn't have done a lot with oracle but the year is defined as an int, so shouldn't you pass 1980 instead of '1980', should you ?
Upvotes: 0