【发布时间】:2016-06-12 01:04:00
【问题描述】:
我有一个带有 id 和 name 的表,其中 id 是主键,bigint 作为数据类型。现在我想更改列,其中 id 作为主键,具有自动递增的值。
我的桌子:
CREATE TABLE test(
testid bigint NOT NULL,
testname character varying(255),
CONSTRAINT test_pkey PRIMARY KEY (testid)
);
更改查询:
ALTER TABLE test ALTER COLUMN testid BIGSERIAL PRIMARY KEY;
执行查询后出现以下错误,
ERROR: syntax error at or near "BIGSERIAL"
LINE 1: ALTER TABLE test ALTER COLUMN testid BIGSERIAL P...
^
********** Error **********
ERROR: syntax error at or near "BIGSERIAL"
SQL state: 42601
Character: 50
【问题讨论】:
标签: sql postgresql primary-key