]> begriffs open source - ai-pg/blob - full-docs/txt/app-dropdb.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / app-dropdb.txt
1
2 dropdb
3
4    dropdb — remove a PostgreSQL database
5
6 Synopsis
7
8    dropdb [connection-option...] [option...] dbname
9
10 Description
11
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. There is no
16    effective difference between dropping databases via this utility and
17    via other methods for accessing the server.
18
19 Options
20
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    -f
31           --force
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.
35
36    -i
37           --interactive
38           Issues a verification prompt before doing anything destructive.
39
40    -V
41           --version
42           Print the dropdb version and exit.
43
44    --if-exists
45           Do not throw an error if the database does not exist. A notice
46           is issued in this case.
47
48    -?
49           --help
50           Show help about dropdb command line arguments, and exit.
51
52    dropdb also accepts the following command-line arguments for connection
53    parameters:
54
55    -h host
56           --host=host
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.
60
61    -p port
62           --port=port
63           Specifies the TCP port or local Unix domain socket file
64           extension on which the server is listening for connections.
65
66    -U username
67           --username=username
68           User name to connect as.
69
70    -w
71           --no-password
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.
77
78    -W
79           --password
80           Force dropdb to prompt for a password before connecting to a
81           database.
82
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.
88
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.
96
97 Environment
98
99    PGHOST
100           PGPORT
101           PGUSER
102           Default connection parameters
103
104    PG_COLOR
105           Specifies whether to use color in diagnostic messages. Possible
106           values are always, auto and never.
107
108    This utility, like most other PostgreSQL utilities, also uses the
109    environment variables supported by libpq (see Section 32.15).
110
111 Diagnostics
112
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.
117
118 Examples
119
120    To destroy the database demo on the default database server:
121 $ dropdb demo
122
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
128 DROP DATABASE demo;
129
130 See Also
131
132    createdb, DROP DATABASE