{
    "mode": "man",
    "parameter": "dropdb",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/dropdb/1/json",
    "generated": "2026-09-01T20:27:32Z",
    "synopsis": "dropdb [connection-option...] [option...] dbname",
    "sections": {
        "NAME": {
            "content": "dropdb - remove a PostgreSQL database\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "dropdb [connection-option...] [option...] dbname\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "dropdb destroys an existing PostgreSQL database. The user who executes this command must be a\ndatabase superuser or the owner of the database.\n\ndropdb is a wrapper around the SQL command DROP DATABASE. There is no effective difference\nbetween dropping databases via this utility and via other methods for accessing the server.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "dropdb accepts the following command-line arguments:\n\ndbname\nSpecifies the name of the database to be removed.\n",
            "subsections": [
                {
                    "name": "-e",
                    "content": "",
                    "flag": "-e"
                },
                {
                    "name": "--echo",
                    "content": "Echo the commands that dropdb generates and sends to the server.\n",
                    "long": "--echo"
                },
                {
                    "name": "-f",
                    "content": "",
                    "flag": "-f"
                },
                {
                    "name": "--force",
                    "content": "Attempt to terminate all existing connections to the target database before dropping it.\nSee DROP DATABASE (DROPDATABASE(7)) for more information on this option.\n",
                    "long": "--force"
                },
                {
                    "name": "-i",
                    "content": "",
                    "flag": "-i"
                },
                {
                    "name": "--interactive",
                    "content": "Issues a verification prompt before doing anything destructive.\n",
                    "long": "--interactive"
                },
                {
                    "name": "-V",
                    "content": "",
                    "flag": "-V"
                },
                {
                    "name": "--version",
                    "content": "Print the dropdb version and exit.\n",
                    "long": "--version"
                },
                {
                    "name": "--if-exists",
                    "content": "Do not throw an error if the database does not exist. A notice is issued in this case.\n\n-?",
                    "long": "--if-exists"
                },
                {
                    "name": "--help",
                    "content": "Show help about dropdb command line arguments, and exit.\n\ndropdb also accepts the following command-line arguments for connection parameters:\n",
                    "long": "--help"
                },
                {
                    "name": "-h _",
                    "content": "--host=host\nSpecifies the host name of the machine on which the server is running. If the value\nbegins with a slash, it is used as the directory for the Unix domain socket.\n",
                    "flag": "-h"
                },
                {
                    "name": "-p _",
                    "content": "--port=port\nSpecifies the TCP port or local Unix domain socket file extension on which the server is\nlistening for connections.\n",
                    "flag": "-p"
                },
                {
                    "name": "-U _",
                    "content": "--username=username\nUser name to connect as.\n",
                    "flag": "-U"
                },
                {
                    "name": "-w",
                    "content": "",
                    "flag": "-w"
                },
                {
                    "name": "--no-password",
                    "content": "Never issue a password prompt. If the server requires password authentication and a\npassword is not available by other means such as a .pgpass file, the connection attempt\nwill fail. This option can be useful in batch jobs and scripts where no user is present\nto enter a password.\n",
                    "long": "--no-password"
                },
                {
                    "name": "-W",
                    "content": "",
                    "flag": "-W"
                },
                {
                    "name": "--password",
                    "content": "Force dropdb to prompt for a password before connecting to a database.\n\nThis option is never essential, since dropdb will automatically prompt for a password if\nthe server demands password authentication. However, dropdb will waste a connection\nattempt finding out that the server wants a password. In some cases it is worth typing -W\nto avoid the extra connection attempt.\n\n--maintenance-db=dbname\nSpecifies the name of the database to connect to in order to drop the target database. If\nnot specified, the postgres database will be used; if that does not exist (or is the\ndatabase being dropped), template1 will be used. This can be a connection string. If so,\nconnection string parameters will override any conflicting command line options.\n",
                    "long": "--password"
                }
            ]
        },
        "ENVIRONMENT": {
            "content": "PGHOST\nPGPORT\nPGUSER\nDefault connection parameters\n\nPGCOLOR\nSpecifies whether to use color in diagnostic messages. Possible values are always, auto\nand never.\n\nThis utility, like most other PostgreSQL utilities, also uses the environment variables\nsupported by libpq (see Section 34.15).\n",
            "subsections": []
        },
        "DIAGNOSTICS": {
            "content": "In case of difficulty, see DROP DATABASE (DROPDATABASE(7)) and psql(1) for discussions of\npotential problems and error messages. The database server must be running at the targeted\nhost. Also, any default connection settings and environment variables used by the libpq\nfront-end library will apply.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "To destroy the database demo on the default database server:\n\n$ dropdb demo\n\nTo destroy the database demo using the server on host eden, port 5000, with verification and\na peek at the underlying command:\n\n$ dropdb -p 5000 -h eden -i -e demo\nDatabase \"demo\" will be permanently deleted.\nAre you sure? (y/n) y\nDROP DATABASE demo;\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "createdb(1), DROP DATABASE (DROPDATABASE(7))\n\nPostgreSQL 16.14                                2026                                       DROPDB(1)",
            "subsections": []
        }
    },
    "summary": "dropdb - remove a PostgreSQL database",
    "flags": [
        {
            "flag": "-e",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--echo",
            "arg": null,
            "description": "Echo the commands that dropdb generates and sends to the server."
        },
        {
            "flag": "-f",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--force",
            "arg": null,
            "description": "Attempt to terminate all existing connections to the target database before dropping it. See DROP DATABASE (DROPDATABASE(7)) for more information on this option."
        },
        {
            "flag": "-i",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--interactive",
            "arg": null,
            "description": "Issues a verification prompt before doing anything destructive."
        },
        {
            "flag": "-V",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--version",
            "arg": null,
            "description": "Print the dropdb version and exit."
        },
        {
            "flag": "",
            "long": "--if-exists",
            "arg": null,
            "description": "Do not throw an error if the database does not exist. A notice is issued in this case. -?"
        },
        {
            "flag": "",
            "long": "--help",
            "arg": null,
            "description": "Show help about dropdb command line arguments, and exit. dropdb also accepts the following command-line arguments for connection parameters:"
        },
        {
            "flag": "-h",
            "long": null,
            "arg": null,
            "description": "--host=host Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket."
        },
        {
            "flag": "-p",
            "long": null,
            "arg": null,
            "description": "--port=port Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections."
        },
        {
            "flag": "-U",
            "long": null,
            "arg": null,
            "description": "--username=username User name to connect as."
        },
        {
            "flag": "-w",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--no-password",
            "arg": null,
            "description": "Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password."
        },
        {
            "flag": "-W",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--password",
            "arg": null,
            "description": "Force dropdb to prompt for a password before connecting to a database. This option is never essential, since dropdb will automatically prompt for a password if the server demands password authentication. However, dropdb will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing -W to avoid the extra connection attempt. --maintenance-db=dbname Specifies the name of the database to connect to in order to drop the target database. If not specified, the postgres database will be used; if that does not exist (or is the database being dropped), template1 will be used. This can be a connection string. If so, connection string parameters will override any conflicting command line options."
        }
    ],
    "examples": [
        "To destroy the database demo on the default database server:",
        "$ dropdb demo",
        "To destroy the database demo using the server on host eden, port 5000, with verification and",
        "a peek at the underlying command:",
        "$ dropdb -p 5000 -h eden -i -e demo",
        "Database \"demo\" will be permanently deleted.",
        "Are you sure? (y/n) y",
        "DROP DATABASE demo;"
    ],
    "see_also": [
        {
            "name": "createdb",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/createdb/1/json"
        },
        {
            "name": "DROPDATABASE",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/DROPDATABASE/7/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Remove a PostgreSQL database.",
        "examples": [
            {
                "description": "Destroy a database",
                "command": "dropdb {{database_name}}"
            },
            {
                "description": "Request a verification prompt before any destructive actions",
                "command": "dropdb {{-i|--interactive}} {{database_name}}"
            },
            {
                "description": "Connect with a specific username and destroy a database",
                "command": "dropdb {{-U|--username}} {{username}} {{database_name}}"
            },
            {
                "description": "Force a password prompt before connecting to the database",
                "command": "dropdb {{-W|--password}} {{database_name}}"
            },
            {
                "description": "Suppress a password prompt before connecting to the database",
                "command": "dropdb {{-w|--no-password}} {{database_name}}"
            },
            {
                "description": "Specify the server host name",
                "command": "dropdb {{-h|--host}} {{host}} {{database_name}}"
            },
            {
                "description": "Specify the server port",
                "command": "dropdb {{-p|--port}} {{port}} {{database_name}}"
            },
            {
                "description": "Attempt to terminate existing connections before destroying the database",
                "command": "dropdb {{-f|--force}} {{database_name}}"
            }
        ]
    }
}