我尝试在PostgreSQL中插入时间戳值时出错?

kif*_*iph 4 postgresql sql-insert

我试图插入以下值

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

具有以下结构的表alltypes

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

弹出以下错误

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...
Run Code Online (Sandbox Code Playgroud)

mu *_*ort 5

错误消息非常自我解释:您正在尝试插入表中包含列的更多值.您的表有七列,但您的VALUES表达式有八个值.

顺便说一句,你应该在INSERT时指定列:

insert into alltypes (state, name, children, distance, budget, checkin, started)
values (...)
Run Code Online (Sandbox Code Playgroud)