4

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 Answer 1

10

Yes, just don't specify a type constraint in the CREATE TABLE statement.

CREATE TABLE mytable ( geog GEOGRAPHY, id SERIAL PRIMARY KEY );
1
  • Thanks, it's exactly what I was looking for. It's a shame I didn't even try this one :-(
    – Romain
    Nov 16, 2010 at 0:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.