我是 Postgres/PostGIS 的新手,目前正在阅读 PostGIS 书籍。当我尝试他们的示例查询之一时,我收到以下错误,指出relation "pk" already exists
. 这是否意味着 2 个表不能具有相同名称的约束?
询问:
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'));
错误:
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