1DROPDB(1) PostgreSQL 12.2 Documentation DROPDB(1)
2
3
4
6 dropdb - remove a PostgreSQL database
7
9 dropdb [connection-option...] [option...] dbname
10
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.
14
15 dropdb is a wrapper around the SQL command DROP DATABASE
16 (DROP_DATABASE(7)). There is no effective difference between dropping
17 databases via this utility and via other methods for accessing the
18 server.
19
21 dropdb accepts the following command-line arguments:
22
23 dbname
24 Specifies the name of the database to be removed.
25
26 -e
27 --echo
28 Echo the commands that dropdb generates and sends to the server.
29
30 -i
31 --interactive
32 Issues a verification prompt before doing anything destructive.
33
34 -V
35 --version
36 Print the dropdb version and exit.
37
38 --if-exists
39 Do not throw an error if the database does not exist. A notice is
40 issued in this case.
41
42 -?
43 --help
44 Show help about dropdb command line arguments, and exit.
45
46 dropdb also accepts the following command-line arguments for connection
47 parameters:
48
49 -h host
50 --host=host
51 Specifies the host name of the machine on which the server is
52 running. If the value begins with a slash, it is used as the
53 directory for the Unix domain socket.
54
55 -p port
56 --port=port
57 Specifies the TCP port or local Unix domain socket file extension
58 on which the server is listening for connections.
59
60 -U username
61 --username=username
62 User name to connect as.
63
64 -w
65 --no-password
66 Never issue a password prompt. If the server requires password
67 authentication and a password is not available by other means such
68 as a .pgpass file, the connection attempt will fail. This option
69 can be useful in batch jobs and scripts where no user is present to
70 enter a password.
71
72 -W
73 --password
74 Force dropdb to prompt for a password before connecting to a
75 database.
76
77 This option is never essential, since dropdb will automatically
78 prompt for a password if the server demands password
79 authentication. However, dropdb will waste a connection attempt
80 finding out that the server wants a password. In some cases it is
81 worth typing -W to avoid the extra connection attempt.
82
83 --maintenance-db=dbname
84 Specifies the name of the database to connect to in order to drop
85 the target database. If not specified, the postgres database will
86 be used; if that does not exist (or is the database being dropped),
87 template1 will be used.
88
90 PGHOST
91 PGPORT
92 PGUSER
93 Default connection parameters
94
95 PG_COLOR
96 Specifies whether to use color in diagnostics messages. Possible
97 values are always, auto, never.
98
99 This utility, like most other PostgreSQL utilities, also uses the
100 environment variables supported by libpq (see Section 33.14).
101
103 In case of difficulty, see DROP DATABASE (DROP_DATABASE(7)) and psql(1)
104 for discussions of potential problems and error messages. The database
105 server must be running at the targeted host. Also, any default
106 connection settings and environment variables used by the libpq
107 front-end library will apply.
108
110 To destroy the database demo on the default database server:
111
112 $ dropdb demo
113
114 To destroy the database demo using the server on host eden, port 5000,
115 with verification and a peek at the underlying command:
116
117 $ dropdb -p 5000 -h eden -i -e demo
118 Database "demo" will be permanently deleted.
119 Are you sure? (y/n) y
120 DROP DATABASE demo;
121
123 createdb(1), DROP DATABASE (DROP_DATABASE(7))
124
125
126
127PostgreSQL 12.2 2020 DROPDB(1)