DROP DATABASE deletes a database: every table in it, every row in those tables, and everything else the database holds.
DROP DATABASE database_name;An example
Section titled “An example”To remove a test copy of the accounts database:
DROP DATABASE ProductionAccountsTest;Only if it exists
Section titled “Only if it exists”Dropping a database that does not exist is an error. MySQL, PostgreSQL and SQL Server accept IF EXISTS, which skips the drop quietly instead, and is handy in setup scripts that may run more than once:
DROP DATABASE IF EXISTS ProductionAccountsTest;Things that can get in the way
Section titled “Things that can get in the way”- Permissions: dropping a database usually needs administrator rights.
- Open connections: most servers refuse to drop a database that someone is still connected to, including you. Connect to a different database before dropping this one.
To empty or remove a single table instead of the whole database, see DROP TABLE.