Let’s learn setting up PostgreSQL and how to create database in PostgreSQL command line and the GUI

PSQL Create Database Command Line (SQL Shell)

Step 1) Open the SQL Shell

Step 2) Press enter five times to connect to the DB

Step 3) Enter the command

Step 4) Enter command \l to get a list of all databases

Step 5) To connect to a Database use PostgreSQL database command

Prompt changes to guru99 which signifies that we are connected to database guru99 and can perform operations like create table, trigger, execute SQL on it.

PostgreSQL Create Database using pgAdmin

Step 1) In the Object Tree, right click and select create a database to Postgres create database

Enter Database Name Comment if any database – optional Click Save

Step 3) DB is created and shown in the Object tree.

Step 4) The right pane gives you the SQL used to create the Database.

Complete syntax to create a database

Here is complete Syntax to create a DB in PostgreSQL Common Errors while using the createdb command

Summary

You can create a database using the psql Windows Command Line (SQL Shell) with the command ” CREATE DATABASE databasename You can also create a database using pgAdmin by following this step: In the Object Tree > right click on Database > Select create a database One of the common errors encountered when create database command fails is that the server is not initialized correctly. Rebooting the server solves the issue