我正在学习Postgres的一个较老的教程,因此它可能可能是自发布以来发生了变化。在教程中(使用psql),我创建一个表,然后执行一些insert
语句。这里是教程和相应的psql
命令导致错误:PostgreSQL:INSERT INTO语法错误
http://www.postgresqlforbeginners.com/2010/11/create-table-and-constraints.html
create table people(
id int PRIMARY KEY,
name varchar NOT NULL
);
insert into people(0,'Steve Jobs');
insert into people(1,'Mike Markkula');
insert into people(2,'Mike Scott');
insert into people(3,'John Sculley');
insert into people(4,'Michael Spindler');
insert into people(5,'Gil Amelio');
insert into people(6,'Mike Scott');
我得到这个错误每个插入语句:
ERROR: syntax error at or near "0"
LINE 1: insert into people(0,'Steve Jobs');
^
我试图复制粘贴,资本的sql命令(即INSERT
),从psql
以外的shell中运行命令,使用"
而不是'
引号添加空格...所有结果都是t他同样的错误。有什么改变或我可能做错了什么?
你缺少'values'关键字:https://www.postgresql.org/docs/current/static/sql-insert.html那个教程是错误的 –
是的,就是这样。我以为我也尝试过,也许我没有'value'而是'values'。不管怎样,谢谢 – DjH