This page in other versions: Unsupported versions: 6.4 / 6.5 / 7.0

Chapter 30. Disk Management

Alternate Locations

It is possible to create a database in a location other than the default location for the installation. Remember that all database access actually occurs through the database backend, so that any location specified must be accessible by the backend.

Either an absolute path name or an environment variable may be specified as a location. Note that for security and integrity reasons, all paths and environment variables so specified have some additional path fields appended.

Note: The environment variable style of specification is to be preferred since it allows the site administrator more flexibility in managing disk storage.

Remember that database creation is actually performed by the database backend. Therefore, any environment variable specifying an alternate location must have been defined before the backend was started. To define an alternate location PGDATA2 pointing to /home/postgres/data, type

% setenv PGDATA2 /home/postgres/data

Usually, you will want to define this variable in the Postgres superuser's .profile or .cshrc initialization file to ensure that it is defined upon system startup.

To create a data storage area in /home/postgres/data, ensure that /home/postgres already exists and is writable. From the command line, type

% initlocation $PGDATA2
Creating Postgres database system directory /home/postgres/data

Creating Postgres database system directory /home/postgres/data/base

To test the new location, create a database test by typing

% createdb -D PGDATA2 test
% destroydb test
Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group