

The following example shows how to delete the hrdb database database that does not have active connections. If these databases are not available, you can create them using the following commands: The following example shows the PostgreSQL DROP DATABASE statement uses the databases created in the PostgreSQL create database tutorial.

Terminate the active connections using the following command:.Locate the target database activities using the following command:.To delete a database that still has active connections: PostgreSQL also provides a dropdb utility program that allows you to delete a database using the DROP DATABASE statement. You must connect to another database (for example, PostgreSQL) to run the DROP DATABASE statement. You also cannot run the DROP DATABASE statement if there are active connections to the database. Only the database owner can run the DROP DATABASE statement. When using the DROP DATABASE statement, be careful as this permanently deletes catalog entries and the data directory. If you try to delete a database that does not exist, PostgreSQL issues a warning. Use IF EXISTS to prevent an error when you delete a database that does not exist. Using prevents an error if you try to delete a database that does not exist.

Where name is the name of the database that you want to delete. You can delete a database using the DROP DATABASE statement. Psql.exe -d postgres -U administrator -h localhost -p 2732 Where clusterdatabasename is the name of the cluster database, admin is the name of the administrator account, host is the host, and port is the port. Psql.exe -d clusterdatabasename -U admin -h host -p port Navigate to installdirectory/pgsq-( version).However, you must first connect to PostgreSQL with psql. If a database is no longer needed, you can delete it.
