How to Create a PostgreSQL Database and Tables in 3 Minutes

Francisco Luna
CodeX
Published in
3 min readJun 3, 2022

--

Photo by Geran de Klerk on Unsplash

For this tutorial. I assume that you have already installed Postgres and pgAdmin. If that’s not the case you can download them from here.

Open pgAdmin and the Query Tool

Every time you open pgAdming, it will ask for the master password so you can access all your databases. On the column on the left, click on Server > Local Postgres > Databases > postgres. This is a Postgres instance that is created when you install it.

Fig 1

After you have clicked on Postgres database, you have to open the query tool. Using this tool, you can write all your SQL statements.

Figure 2

Once opened, on the right side, a text editor will open for writing SQL commands. The Scratch Pad is used to hold text or scripts only.

Creating a Database and Tables

To create a database, we need to run the following command:

CREATE DATABASE databasetutorial;

--

--