How to do it...

Carry out the following steps to create and organize a database:

  1. Create a database named chapter10 by executing the following command:
      CREATE DATABASE chapter10;
  1. Create a schema named postgis in the chapter10 database, where we will install PostGIS. Execute the following command:
      CREATE SCHEMA postgis;
  1. Install PostGIS in the postgis schema of the chapter10 database:
    1. If you are running PostgreSQL 9.1 or a newer version, use the CREATE EXTENSION statement:
               CREATE EXTENSION postgis WITH SCHEMA postgis;

The WITH SCHEMA clause of the CREATE EXTENSION statement instructs PostgreSQL to install PostGIS and its objects in the postgis schema.

  1. Check whether or not the PostGIS installation has succeeded by running the following ...

Get PostGIS Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.