无法在 Postgres 中创建特定列

Not able to create the specific column in Postgres

我在 Postgres 数据库中遇到以下问题。
我有 table kart_user,我无法以用户
创建列 我收到以下错误。

syntax error at or near "user" 

我可以创建其他列作为用户,usersss...
我该如何解决这个问题?

user是保留字,所以需要加引号:

create table kart_user
(
  id integer not null primary key,
  "user"  varchar(20)
);

但通常您应该避免使用带引号的标识符并为该列找到一个不同的名称。

手册中有关标识符语法的更多详细信息:
http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

完整的关键字列表也可以在手册中找到:
http://www.postgresql.org/docs/current/static/sql-keywords-appendix.html


一旦你定义了一个带引号的标识符,你必须总是引用列名:

insert into kart_user (user) values ('Arthur');