【发布时间】:2012-12-16 09:02:57
【问题描述】:
我正在通过“PostGIS in Action”一书学习 PostgreSQL 和 PostGIS。我的问题来自 Pg。清单 3.4 中的 66。
我的代码如下:
CREATE TABLE ch03.paris_polygons(tags hstore, CONSTRAINT paris_polygons_pk PRIMARY KEY (gid)
)
INHERITS (ch03.paris);
ALTER TABLE ch03.paris_polygons NO INHERIT ch03.paris;
INSERT INTO ch03.paris_polygons(osm_id, ar_num, geom, tags, feature_name, feature_type)
SELECT osm_id, ar_num, ST_Multi(geom) As geom, tags, tags->'name',
COALESCE(tags->'tourism', tags->'railway','other')::varchar(50) As feature_type
FROM ch03.paris_hetero
WHERE ST_GeometryType(geom) LIKE '%Polygon';
SELECT populate_geometry_columns('ch03.paris_polygons'::regclass);
ALTER TABLE ch03.paris_polygons INHERIT ch03.paris;
运行代码后我收到此错误:
ERROR: child table "paris_polygons" has different type for column "geom"
SQL state: 42804
我用谷歌搜索了这个:
-204 (ECPG_INT_FORMAT)
The host variable is of type int and the datum in the database is of a different type and contains a value that cannot be interpreted as an int. The library uses strtol() for this conversion. (SQLSTATE 42804)
什么 psql 命令可以帮助我了解如何合并这些命令?
再次感谢大家的帮助!
【问题讨论】:
-
继承
paris然后立即将ALTER变成NO INHERIT有什么问题?这很奇怪。 -
我不确定,因为我对 PostgreSQL 非常陌生。代码取自书中。
-
搜索结果引用了ECPG。除非您使用 ECPG,否则它是无关紧要的。你在代码的哪一行得到了错误?
paris的定义是什么?显示来自psql的\d paris输出。 -
父表是否有像
geometry(Polygon,4326)这样的typmod? -
@Craig Ringer 不幸的是,对于 PostgreSQL 9.1,我不能使用 \d。这与 [stackoverflow.com/a/109337/1777654] 相同还是有其他方法可以检查?
标签: postgis postgresql-9.1 type-conversion