initlocation

Name

initlocation -- Create a secondary PostgreSQL database storage area

Synopsis

initlocation directory

Options

directory

File system location to place the secondary database storage area.

Description

initlocation creates a new PostgreSQL secondary database storage area. If the argument does not contain a slash and is not a valid path, it is assumed to be an environment variable, which is referenced.

In order to use this command you must be logged in (using su, for example) as the database superuser.

Usage

To create a database in an alternative location, you must first set the value of the environment variable:
$ export PGDATA2=/opt/postgres/data
Next, stop and start postmaster so it sees the PGDATA2 environment variable.
$ pg_ctl stop
$ pg_ctl start
(The system must be configured so the postmaster sees PGDATA2 every time it starts.) Finally, enter:
$ initlocation PGDATA2
$ createdb -D PGDATA2 testdb

Alternatively, if you allow absolute paths, you could write:
$ initlocation /opt/postgres/data
$ createdb -D /opt/postgres/data/testdb testdb