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. See the examples in the "Usage" section.
In order to use this command you must be logged in as the database superuser.
To create a database in an alternative location, you must first set the value of the environment variable:
$ export PGDATA2=/opt/postgres/data |
$ pg_ctl stop $ pg_ctl start |
$ initlocation PGDATA2 $ createdb -D PGDATA2 testdb |