Creating and Deleting Databases in PostgreSQL (using command line)
One can create and delete (drop) a database in PostgreSQL using either:
- pgAdmin or
- Command Line
Here we will be doing it using the command line.
Create Database:
Type the command CREATE DATABASE db_name; to create a new database with the name specified as db_name.
Once the database is created, it will show up in the list obtained by \l command.

By default, the owner of the created database is postgres. One can use a different owner by specifying it in the create database command as follows:

To connect to an existing database, type \c db_name;

Delete (drop) Database:
To drop an existing database, we use the command: Drop database db_name;

Remember: You can't drop a currently open database!!

1
