23.5. Destroying a Database

| 23.5. Destroying a Database |                             |                              |                  |                                   |
|:---------------------------:|-----------------------------|------------------------------|------------------|-----------------------------------|
|[Prev](manage-ag-config.html)|[Up](managing-databases.html)|Chapter 23. Managing Databases|[Home](index.html)| [Next](manage-ag-tablespaces.html)|

---

## 23.5. Destroying a Database

 Databases are destroyed with the command [DROP DATABASE](sql-dropdatabase.html):[]()

```
DROP DATABASE name;

```

 Only the owner of the database, or a superuser, can drop a database. Dropping a database removes all objects that were contained within the database. The destruction of a database cannot be undone.

 You cannot execute the `DROP DATABASE` command while connected to the victim database. You can, however, be connected to any other database, including the `template1` database. `template1` would be the only option for dropping the last user database of a given cluster.

 For convenience, there is also a shell program to drop databases, [dropdb](app-dropdb.html):[]()

```
dropdb dbname

```

 (Unlike `createdb`, it is not the default action to drop the database with the current user name.)

---

|[Prev](manage-ag-config.html)|[Up](managing-databases.html)| [Next](manage-ag-tablespaces.html)|
|:----------------------------|:---------------------------:|----------------------------------:|
|23.4. Database Configuration |     [Home](index.html)      |         23.6. Tablespaces         |

 // \<![CDATA[ \<-- For SVG support if ('WebSocket' in window) { (function() { function refreshCSS() { var sheets = [].slice.call(document.getElementsByTagName("link")); var head = document.getElementsByTagName("head")[0]; for (var i = 0; i \< sheets.length; ++i) { var elem = sheets[i]; head.removeChild(elem); var rel = elem.rel; if (elem.href && typeof rel != "string" || rel.length == 0 || rel.toLowerCase() == "stylesheet") { var url = elem.href.replace(/(&|\\?)\_cacheOverride=\\d+/, ''); elem.href = url + (url.indexOf('?') \>= 0 ? '&' : '?') + '\_cacheOverride=' + (new Date().valueOf()); } head.appendChild(elem); } } var protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://'; var address = protocol + window.location.host + window.location.pathname + '/ws'; var socket = new WebSocket(address); socket.onmessage = function(msg) { if (msg.data == 'reload') window.location.reload(); else if (msg.data == 'refreshcss') refreshCSS(); }; console.log('Live reload enabled.'); })(); } // ]]\>