PostgreSQL – CREATE Database

PostgreSQL CREATE DATABASE – using SQL Shell

Start the SQL Shell (psql) and run the following SQL Query.

CREATE DATABASE mydb;

where  mydb is the database name that we are creating now.

PostgreSQL CREATE DATABASE

A new database with the name mydb is created successfully.

Create Database using pgAdmin

When you install PostgreSQL, pgAdmin is installed. Start pgAdmin from your start menu.

PostgreSQL pgAdmin

Right click on the Databases, then Create, Database.

PostgreSQL Create Database

A new window ‘Create – Database‘ appears as shown below.

PostgreSQL Create Database

Provide the database name against Database field. You can select the owner for this database. Also provide a comment.

This window has other tabs, where you can customize your Database while its creation.

Or you can click on Save button to create the database.

Create – Database: Definition

You can provide the details like Encoding, Template, Tablespace, Collation, Character type, and Connection limit to the database.

Create – Database: Security

You can provide privileges to users and also add Security labels. Using Security labels, you can manage the security of all the databases.

Create – Database: Parameters

Create – Database: SQL

You can also provide your custom SQL code to create Database, using SQL Tab.

Save Database

Once you click on the Save button, a new PostgreSQL database is created as shown below.

PostgreSQL New Database Created

Conclusion

In this PostgreSQL Tutorial, we learned to create a PostgreSQL Database using psql and pgAdmin.