How to use geometry data type for postgres table?

I installed the postgres database (version 9.1) and tried to create a table able to store st_geometry with the following query:

CREATE TABLE sensitive_areas (area_id integer, name varchar(128), zone st_geometry);

But I get the error as follows:

ERROR:  type "st_geometry" does not exist

Do I need to configure my postgres installation again to enable the geometry data type.

+5
source share
2 answers
CREATE TABLE sensitive_areas (area_id integer, name varchar(128), zone geometry);

You must have PostGISdb installed by you for this to work.

+4
source

The correct type name geometry. If you are using PostGIS 2.0, you can use typmod:

-- If you haven't done so already
CREATE EXTENSION postgis;

-- Make a table of Polygons, using long/lat coords
CREATE TABLE sensitive_areas (
    area_id integer primary key,
    name varchar(128),
    zone geometry(Polygon,4326)
);
+11
source

All Articles