Step by step guide to setup PostgreSQL for beginners

Dulana Hansisi
5 min readSep 19, 2021

--

Let’s download, install and start scripting in PostgreSQL.

PostgreSQL is a powerful, open source object-relational database system with over 30 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance.

As it clearly discourses, PostgreSQL is one of the most popular enterprise database. It is being used for data analysis in a wide scale as well. On the other hand, it provides an convenient environment for the beginners to script and try.

So without further ado, let’s dive into the step by step tutorial.

Download PostgreSQL latest version

Click this link to visit the download page.

Here you can select the correct download package for your OS. Once you have downloaded it, double click on the downloaded file to install PostgreSQL to your computer.

Install PostgreSQL

After double clicking, you’ll see a wizard as in the below image. Just click next to proceed.

After that, you’ll be asked to set the installation directory. You may select is you prefer.

Then you’ll be asked to select the download components. Make sure you check pgAdmin4 mandatorily as it provides the GUI for database management

After the above UI, the process is straightforward and complete the installation.

Once you click on finish button, it’ll automatically pop up a message as in the below UI to install stack builder. However, you can skip it for the moment. It’s not required to complete the installation. Just hit cancel there.

Now your computer is set up with PostgreSQL. Let’s see where you can find it.

Run PostgreSQL

Under the windows menu, you’ll be able to find a new folder created for PostgreSQL. Amidst multiple files, you may click on pgAdmin 4 to launch the admin panel.

If you are after a fresh installation, you’ll be asked to setup a port and a password. There you just give a port and a password you can remember.

After the authentication, you’ll be landed on a page like in the below UI. It contains different dashboards, tabs and letters and many more but don’t worry about that.

Once the setup is completed, you should need to know how to create a database.

Create a database

As in the below image, right click on “PostgreSQL 13” which comes under Servers. In the right click menu, navigate to Create →Database.

Then just give a database name and a description.

Create a table

Once the database is create, it’ll show you a lengthy list of containing files on the left side panel. You may have to expand the tab which is named in the created database. Then go to Schemas → Tables and right click Tables. It’ll open you up a menu. You can create a table easily clicking “Table” but let’s try something fascinating.

So instead of clicking “Table” , let’s click on “Query Tool” which will open up a scripting space for you to write and run SQL command. The scripting space looks like this.

You can see the database name appears on the highlighted tab. Which simply means that all the scripts you write will be within the database.

You may use ,

CREATE TABLE <table name> (

<variableName> <Data type>,

<variableName> <Data type>

);

to create tables as you want. Check this documentation to get to know about the available data types in PostgreSQL.

After writing the script, click on the button which is akin to a play button to run the SQL command you wrote.

If the scripts are valid and successful, you’ll see a success message like this.

You can double check the way the tables are created under the databases list.

Now you are all set to add data to the tables and proceed with your scripting.

Insert data to a table

Additionally, let me tell you the script to add values to the tables. Even though the normal script is

INSERT INTO “<Table Name>” VALUES (<value 1>,<value 2>,…) in PostgreSQL, we have to use below query.

INSERT INTO PUBLIC.“<Table Name>” VALUES (<value 1>,<value 2>,…)

as tables are under the public folder.

Even though SQL is a common language, the way it is used depends on the database system.

Happy scripting with PostgreSQL !!!
Until next time

--

--

Dulana Hansisi

I’'m searching for my balance between heart and head..