|Prev||Chapter 22. Disk Management||Next|
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
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.