4 dropdb — remove a PostgreSQL database
8 dropdb [connection-option...] [option...] dbname
12 dropdb destroys an existing PostgreSQL database. The user who executes
13 this command must be a database superuser or the owner of the database.
15 dropdb is a wrapper around the SQL command DROP DATABASE. There is no
16 effective difference between dropping databases via this utility and
17 via other methods for accessing the server.
21 dropdb accepts the following command-line arguments:
24 Specifies the name of the database to be removed.
28 Echo the commands that dropdb generates and sends to the server.
32 Attempt to terminate all existing connections to the target
33 database before dropping it. See DROP DATABASE for more
34 information on this option.
38 Issues a verification prompt before doing anything destructive.
42 Print the dropdb version and exit.
45 Do not throw an error if the database does not exist. A notice
46 is issued in this case.
50 Show help about dropdb command line arguments, and exit.
52 dropdb also accepts the following command-line arguments for connection
57 Specifies the host name of the machine on which the server is
58 running. If the value begins with a slash, it is used as the
59 directory for the Unix domain socket.
63 Specifies the TCP port or local Unix domain socket file
64 extension on which the server is listening for connections.
68 User name to connect as.
72 Never issue a password prompt. If the server requires password
73 authentication and a password is not available by other means
74 such as a .pgpass file, the connection attempt will fail. This
75 option can be useful in batch jobs and scripts where no user is
76 present to enter a password.
80 Force dropdb to prompt for a password before connecting to a
83 This option is never essential, since dropdb will automatically
84 prompt for a password if the server demands password
85 authentication. However, dropdb will waste a connection attempt
86 finding out that the server wants a password. In some cases it
87 is worth typing -W to avoid the extra connection attempt.
89 --maintenance-db=dbname
90 Specifies the name of the database to connect to in order to
91 drop the target database. If not specified, the postgres
92 database will be used; if that does not exist (or is the
93 database being dropped), template1 will be used. This can be a
94 connection string. If so, connection string parameters will
95 override any conflicting command line options.
102 Default connection parameters
105 Specifies whether to use color in diagnostic messages. Possible
106 values are always, auto and never.
108 This utility, like most other PostgreSQL utilities, also uses the
109 environment variables supported by libpq (see Section 32.15).
113 In case of difficulty, see DROP DATABASE and psql for discussions of
114 potential problems and error messages. The database server must be
115 running at the targeted host. Also, any default connection settings and
116 environment variables used by the libpq front-end library will apply.
120 To destroy the database demo on the default database server:
123 To destroy the database demo using the server on host eden, port 5000,
124 with verification and a peek at the underlying command:
125 $ dropdb -p 5000 -h eden -i -e demo
126 Database "demo" will be permanently deleted.
127 Are you sure? (y/n) y
132 createdb, DROP DATABASE