Error trying 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'); 

to the alltypes table 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 appears

 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... 
+4
source share
1 answer

The error message is pretty clear: you are trying to insert more values ​​that have a column. Your table has seven columns, but the VALUES expression has eight values.

By the way, you should always specify columns when you are INSERT:

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

Source: https://habr.com/ru/post/1433699/


All Articles