Yogesh Chauhan's Blog

DROP DATABASE (remove a database) from Postgres

in Postgres on June 20, 2020

DROP DATABASE (remove a database) from Postgres

Syntax


DROP DATABASE [ IF EXISTS ] name

DROP DATABASE drops a database.

It removes the catalog entries for the database and deletes the directory containing the data.

It can only be executed by the database owner.

Also, it cannot be executed while you or anyone else are connected to the target database.

Connect to postgres or any other database to issue this command.

DROP DATABASE cannot be undone. Use it with care!

Parameters

IF EXISTS: Do not throw an error if the database does not exist. A notice is issued in this case.

name: The name of the database to remove.

DROP DATABASE cannot be executed inside a transaction block.

This command cannot be executed while connected to the target database. Thus, it might be more convenient to use the program dropdb instead, which is a wrapper around this command.

Credit: Postgresql


Most Read

#1 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
How to host Google fonts on your server and add them using CSS?CSSList of social media icon logo color codes in HEXMiscellaneousSolution to “Call to undefined function mysql_error()” in RevSlider WordPress PluginWordPressWP_Query Class in WordPressWordPressHow to Check If a Variable is an Integer, a Float, a Number, NaN, an Infinite or a Numeric in PHP?PHPinclude, include_once, require, require_once in PHPPHPHow to create a simple slider with CSS and jQuery?CSSDoes :is() pseudo selector hint at CSS preprocessing in the future?CSSHow to zoom an image inside a box on hover?CSSWhat is iFrame in HTML? Why do we need it?HTMLHow to position an image on top of another image using CSS?CSSAggregate Functions Examples in Postgres for BeginnersPostgres