[英]Relation “pk” already exists in Postgresql 9.1
I am new to Postgres/PostGIS, currently following a PostGIS book. 我是Postgres / PostGIS的新手,目前正在阅读PostGIS书籍。 When I tried one of their example's query, I get the error below stating that the
relation "pk" already exists
. 当我尝试他们的示例查询之一时,出现以下错误,指出
relation "pk" already exists
。 Does this mean that 2 tables cannot have constraints with the same names? 这是否意味着2个表不能具有名称相同的约束?
Query: 查询:
CREATE TABLE roads(gid serial PRIMARY KEY, road_name character varying(100));
SELECT AddGeometryColumn('public', 'roads', 'geom', 4269, 'LINESTRING',2);
CREATE TABLE roads_NE(CONSTRAINT pk PRIMARY KEY (gid))
INHERITS (roads);
ALTER TABLE roads_NE
ADD CONSTRAINT chk CHECK (state
IN ('MA', 'ME', 'NH', 'VT', 'CT', 'RI'));
CREATE TABLE roads_SW(CONSTRAINT pk PRIMARY KEY (gid))
INHERITS (roads);
ALTER TABLE roads_SW
ADD CONSTRAINT chk CHECK (state IN ('AZ', 'NM', 'NV'));
Error: 错误:
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pk" for table "roads_sw"
ERROR: relation "pk" already exists
********** Error **********
ERROR: relation "pk" already exists
SQL state: 42P07
Yes. 是。 You need to use a different name within a database
您需要在数据库中使用其他名称
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.