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 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Aug 15 Is PHP still good for back-end programming? #Aug 10 How to create a multisite network in WordPress? #Aug 3 How to create a circle that follows a cursor using JavaScript and CSS? #Aug 3 How to make a curtain slider using jQuery and CSS? #Aug 2 How to progressively load images and add a blurry placeholder? #Aug 1 How to create a placeholder loader (throbber) using CSS?
You might also like these
How to show widgets on the Appearance tab in WordPress?WordPressIs there a CSS parent selector?CSSCrypto.getRandomValues() method in JavaScriptJavaScriptHow to auto-resize textarea based on text input using JavaScript or jQuery?JavaScriptAvoid using new Array() in JavaScriptJavaScriptHow to get user’s Browser and Operating Systems information using PHP?PHPHow to use Context in React?ReactCreate dynamic selectors using SCSS (Sass)SCSSActions vs. Filters: hooks in WordPressWordPressOOP, Class and Objects Strategies For Beginners (PHP)PHPShort-Circuit Evaluation in JavaScriptJavaScriptGive buttons accessible namesUI/UX