$PGDATA/base/dbname
The location of the files corresponding to the database dbname.
Destroy an existing database
destroydb [-i] [-a system] [-h host] [-p port] -u [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 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).
-u
Use password authentication. Prompts for username and password.
# 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 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.
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.
You do not have permission to destroy databases; contact your Postgres site administrator.
The database to be removed does not have an entry in the “pg_database” class.
You are not DBA for the specified database.
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.
The command internally runs drop database from psql connected to the template1 database to perform the operation.
5 releases since Debian 1.2 (Rex); the text changed 3 times.
-i since Debian 2.0 (Hamm);
-u since Debian 2.2 (Potato).