{
    "mode": "man",
    "parameter": "DROP_DATABASE",
    "section": "7",
    "url": "https://www.chedong.com/phpMan.php/man/DROP_DATABASE/7/json",
    "generated": "2026-05-30T05:14:39Z",
    "synopsis": "DROP DATABASE [ IF EXISTS ] name [ [ WITH ] ( option [, ...] ) ]\nwhere option can be:\nFORCE",
    "sections": {
        "NAME": {
            "content": "DROPDATABASE - remove a database\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "DROP DATABASE [ IF EXISTS ] name [ [ WITH ] ( option [, ...] ) ]\n\nwhere option can be:\n\nFORCE\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "DROP DATABASE drops a database. It removes the catalog entries for the database and deletes\nthe directory containing the data. It can only be executed by the database owner. It cannot\nbe executed while you are connected to the target database. (Connect to postgres or any other\ndatabase to issue this command.) Also, if anyone else is connected to the target database,\nthis command will fail unless you use the FORCE option described below.\n\nDROP DATABASE cannot be undone. Use it with care!\n",
            "subsections": []
        },
        "PARAMETERS": {
            "content": "IF EXISTS\nDo not throw an error if the database does not exist. A notice is issued in this case.\n\nname\nThe name of the database to remove.\n\nFORCE\nAttempt to terminate all existing connections to the target database. It doesn't\nterminate if prepared transactions, active logical replication slots or subscriptions are\npresent in the target database.\n\nThis terminates background worker connections and connections that the current user has\npermission to terminate with pgterminatebackend, described in Section 9.27.2. If\nconnections would remain, this command will fail.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "DROP DATABASE cannot be executed inside a transaction block.\n\nThis command cannot be executed while connected to the target database. Thus, it might be\nmore convenient to use the program dropdb(1) instead, which is a wrapper around this command.\n",
            "subsections": []
        },
        "COMPATIBILITY": {
            "content": "There is no DROP DATABASE statement in the SQL standard.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "CREATE DATABASE (CREATEDATABASE(7))\n\n\n\nPostgreSQL 14.23                                2026                                DROP DATABASE(7)",
            "subsections": []
        }
    },
    "summary": "DROPDATABASE - remove a database",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "CREATEDATABASE",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/CREATEDATABASE/7/json"
        },
        {
            "name": "DATABASE",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/DATABASE/7/json"
        }
    ]
}