问题
In PostgreSQL 9 + PostGIS 1.5, is there a way to create a "generic" GEOGRAPHY column? By that I mean a column that would accept POINTs as well as POLYGONs, LINESTRINGs, etc. Until now, I've only seen columns like GEOGRAPHY(POINT,4326) on the Internet.
If that is not possible, then how would you design (from a DB point of view) an entity that is linked to a random geographical object (point, polygon, whatever)? Should I create 3, 4, 5 different tables for each type of geographical object I'd like to support? (1 table for POINT objets, 1 table for POLYGON objects and so on)?
Thanks in advance.
Romain
回答1:
Yes, just don't specify a type constraint in the CREATE TABLE statement.
CREATE TABLE mytable ( geog GEOGRAPHY, id SERIAL PRIMARY KEY );
来源:https://stackoverflow.com/questions/4166529/having-a-generic-geography-column-with-postgis