kifcaliph
kifcaliph

Reputation: 321

Error when I try to insert a timestamp value in PostgreSQL?

I am trying to insert the following value

('PA', 'Hilda Blainwood', 3, 10.7, 4308.20, '9/8/1974', '9:00', '07/03/1996 10:30:00');

into table alltypes with the following structure

create table alltypes( state CHAR(2), name CHAR(30), children INTEGER, distance FLOAT,
budget NUMERIC(16,2), checkin TIME, started TIMESTAMP);

the following error pops up

test=# insert into alltypes VALUES('PA', 'Hilda Blainwood', 3, 10.7, 4308.20, '9/8/1974',
'9:00', '07/03/1996 10:30:00');
ERROR:  INSERT has more expressions than target columns
LINE 1: ...Blainwood', 3, 10.7, 4308.20, '9/8/1974', '9:00', '07/03/199...

Upvotes: 4

Views: 4711

Answers (1)

mu is too short
mu is too short

Reputation: 434585

The error message is pretty self explanatory: you're trying to insert more values that the table has columns. Your table has seven columns but your VALUES expression has eight values.

BTW, you should always specify the columns when you INSERT:

insert into alltypes (state, name, children, distance, budget, checkin, started)
values (...)

Upvotes: 5

Related Questions