PostgreSQL DROP Database

In PostgreSQL drop table is used to remove or delete an existing table from a PostgreSQL database.Deleting a table will cause loss of all information stored in the table.PostgreSQL provides two ways of creating a new database −

1. Using DROP DATABASE, an SQL command:-It removes the catalog entries for the database and deletes the directory containing the data.

2. Using dropdb Command:-dropdb is a command-line wrapper around the SQL command DROP DATABASE.



DROP DataBase Syntax :

The syntax of the DROP DataBase is −

\\Using DROP DATABASE

DROP DATABASE [ IF EXISTS ] name

-----------------------------

\\Using dropdb Command

dropdb  [option...] dbname


DROP DataBase Example :

The Example of the DROP DataBase is −

postgres=# DROP DATABASE testdb;
postgres-# 

After a database is Dropped, you can view it in the list of databases with the following postgreSQL command: SHOW DATABASES;

SHOW DATABASES;
----------------
testDB            
letsfindcourse     
LfcDB              
test   
 




Visit :


Discussion


* You must be logged in to add comment.