4

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...

1 Answer 1

5

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 (...)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.