Difference between revisions of "Delete database"

From wikieduonline
Jump to navigation Jump to search
 
(31 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 +
* https://www.postgresql.org/docs/current/sql-dropdatabase.html
  
= =[[PostgreSQL]] ==
+
== [[PostgreSQL]] ==
* <code>DROP DATABASE [IF EXISTS] database_name;</code>
+
[[DROP DATABASE]] [IF EXISTS] [[my_database_name]][[;]]
DROP DATABASE
+
Do not forget the <code>;</code> at the end of the line
  
 +
 +
 +
[[DROP DATABASE]] [IF EXISTS] [[my_database_name]] (FORCE) [[;]]
 +
Note: FORCE introduced in 2022 ([[PostgreSQL 13]])
 +
 +
DROP DATABASE database_name;
 +
Output:
 +
DROP DATABASE
 +
 +
DROP DATABASE database_name (FORCE);
 +
 +
 +
ERROR: database "XXXXX" is being accessed by other users
 +
DETAIL: There are 4 other sessions using the database
 +
 +
Related terms:
 +
* <code>[[sudo -u postgres psql]]</code>
 +
* <code>[[community.postgresql.postgresql_db_module]]: state: [[absent]]</code>
 +
 +
== Related ==
 +
* <code>[[DELETE]]</code>
 +
* <code>[[DROP TABLE]]</code>
 +
* <code>[[CREATE DATABASE]]</code>
 +
* <code>[[\list]]</code>
 +
* [[PostgreSQL superuser]]
 +
* <code> [[ALTER DATABASE]]</code>
 +
* <code> [[ERROR: must be owner of database]]</code>
 +
 +
* <code> [[GRANT "your-defined role" TO "your username";]]</code
 +
>
  
 
== See also ==
 
== See also ==
* {{TOC operation databases}}
+
* {{DROP}}
 
+
* {{Database ops}}
 +
* {{Role}}
  
 
[[Category:Databases]]
 
[[Category:Databases]]

Latest revision as of 12:28, 16 December 2022

PostgreSQL[edit]

DROP DATABASE [IF EXISTS] my_database_name;

Do not forget the ; at the end of the line


DROP DATABASE [IF EXISTS] my_database_name (FORCE) ;
Note: FORCE introduced in 2022 (PostgreSQL 13)
DROP DATABASE database_name;
Output:
DROP DATABASE
DROP DATABASE database_name (FORCE);


ERROR: database "XXXXX" is being accessed by other users
DETAIL: There are 4 other sessions using the database

Related terms:

Related[edit]

See also[edit]

Advertising: