PostgreSQL Contents
destroydb - destroy an existing database
destroydb [-i]
[-a system] [-h host] [-p port] [dbname]
Destroydb destroys
an existing database. To execute this command, the user must be the database
administrator, or DBA, for this database. The program runs silently; no
confirmation message will be displayed. After the database is destroyed,
a Unix shell prompt will reappear.
Destroydb is a shell script that invokes
psql. Hence, a postmaster process must be running on the database server
host before destroydb is executed. In addition, the PGOPTION
and PGREALM
environment variables will be passed on to psql and processed as described
in psql(1)
.
The optional argument dbname specifies the name of the database
to be destroyed. All references to the database are removed, including
the directory containing this database and its associated files. Dbname
defaults to the value of the USER
environment variable.
Destroydb understands
the following command-line options:
- -i
- Prompts before destroying a database
(interactive).
- -a system
- Specifies an authentication system system (see
pgintro(1)
) to use in connecting to the postmaster process. This option
no longer has any effect.
- -h host
- Specifies the hostname of the machine
on which the postmaster is running. Defaults to using local Unix domain
sockets.
- -p port
- Specifies the TCP/IP port or local Unix domain socket
file extension on which the postmaster is listening for connections. Defaults
to 5432, or the value of the PGPORT
environment variable (if set).
# destroy the demo database
destroydb demo
# destroy the demo database
using the postmaster on host eden, port 5000.
destroydb -p 5000 -h eden
demo
- $PGDATA/base/dbname
- The location of the files corresponding
to the database dbname.
destroydb(l)
, createdb(1)
, initdb(1)
,
psql(1)
. postmaster(1)
.
- Error: Failed to connect to backend
(host=xxx, port=xxx)
- Destroydb could not attach to the postmaster process
on the specified host and port. If you see this message, ensure that the
postmaster is running on the proper host and that you have specified the
proper port. If your site uses an authentication system, ensure that you
have obtained the required authentication credentials.
- user `username' is
not in `pg_user'
- You do not have a valid entry in the relation `pg_user'
and cannot do anything with Postgres at all; contact your Postgres site
administrator.
- user `username' is not allowed to create/destroy databases
- You do not have permission to destroy databases; contact your Postgres
site administrator.
- database `dbname' does not exist
- The database to be
removed does not have an entry in the `pg_database' class.
- database `dbname'
is not owned by you
- You are not DBA for the specified database.
- database
destroy failed on dbname
- An internal error occurred in psql or the backend
server. Contact your Postgres site administrator to ensure that ensure
that the files and database entries associated with the database are completely
removed.
Table of Contents