Spatially enabled Postgres database

If you have Ubuntu 12.04, then you should have PostgreSQL 9.1, which makes things awesome for PostGIS 2.0, where you can use use the new EXTENSION framework. To spatially enable a database, use the DDL from a SQL window:

CREATE EXTENSION postgis;

See other details for installing PostGIS 2.0 from source for Ubuntu 12.04 here.


If you are using PostGIS 1.5, you will need the enabler scripts on "mydb", run from the shell:

sudo -u postgres createdb mydb
sudo -u postgres psql -d mydb -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
sudo -u postgres psql -d mydb -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql
sudo -u postgres psql -d mydb -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis_comments.sql

While your database is technically spatial at this point, you would only be working with the inbuilt pg geometry types.

In order to complete your installation, you do need to run the scripts as suggested.

You can find them in your /usr/share/postgresql/[version number]/contrib/ postgis sub-directory.

You should see the following:

legacy_minimal.sql    postgis_upgrade_20_minor.sql    spatial_ref_sys.sql
legacy.sql            raster_comments.sql             topology_comments.sql
postgis_comments.sql  rtpostgis_legacy.sql            uninstall_legacy.sql
postgis_restore.pl    rtpostgis.sql                   uninstall_postgis.sql
postgis.sql           rtpostgis_upgrade_20_minor.sql  uninstall_rtpostgis.sql