1DROPDB(1) PostgreSQL 12.6 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. This can be a connection string. If so,
88 connection string parameters will override any conflicting command
89 line options.
90
92 PGHOST
93 PGPORT
94 PGUSER
95 Default connection parameters
96
97 PG_COLOR
98 Specifies whether to use color in diagnostic messages. Possible
99 values are always, auto and never.
100
101 This utility, like most other PostgreSQL utilities, also uses the
102 environment variables supported by libpq (see Section 33.14).
103
105 In case of difficulty, see DROP DATABASE (DROP_DATABASE(7)) and psql(1)
106 for discussions of potential problems and error messages. The database
107 server must be running at the targeted host. Also, any default
108 connection settings and environment variables used by the libpq
109 front-end library will apply.
110
112 To destroy the database demo on the default database server:
113
114 $ dropdb demo
115
116 To destroy the database demo using the server on host eden, port 5000,
117 with verification and a peek at the underlying command:
118
119 $ dropdb -p 5000 -h eden -i -e demo
120 Database "demo" will be permanently deleted.
121 Are you sure? (y/n) y
122 DROP DATABASE demo;
123
125 createdb(1), DROP DATABASE (DROP_DATABASE(7))
126
127
128
129PostgreSQL 12.6 2021 DROPDB(1)