PostgreSQL — Story of the World’s Most Loved Advances Open Source Database (Part 1)

PART 1: Introduction and Installation

Shritam Kumar Mund
4 min readJul 18, 2020

Databases have evolved dramatically since their inception in the early 1960s. There are many different types of databases. The best database for a specific organization depends on how the organization intends to use the data.

Why PostgreSQL?

PostgreSQL, also known as Postgres, is the most advanced open-source relational database in the world. The fastest-growing major database has taken the second spot this year on the top database by developer preference on the 2020 Stack Overflow Developer Survey.

It is standing as the second most loved database (behind Redis).

PostgreSQL is open source, robust, high performance and it comes with a lot of great features. And for that reason, a lot of organizations are using it for their back-end applications.

Installation

The best way of learning any database is to get your hands dirty by pretty much learning the raw commands behind it. We are going to use an interactive shell called PSQL.

PSQL is the interactive terminal for working with Postgres. It enables you to type in queries interactively, issue them to PostgreSQL, and see the query results.

Download recent version of the PostgreSQL database as per your OS.

Windows user:

  • Step 1: Go to the PostgreSQL database download page. Select the latest Postgre version for windows as per your environment and click the Download Button.
  • Step 2: Install it after download, and click next, until you have asked for a password.
  • Step 3: Enter the superuser password. Make a note of it and click next.
  • Step 4: Leave the port number default, click next.
  • Step 5: Uncheck that Stack Builder option and click finish.
  • Step 6: To launch PSQL go to Start Menu and search SQL Shell or psql. And open it.
  • Step 7: You can see that it’s prompting you to enter a server so if you were to connect to a remote server this is where you would add the actual URL but because we are testing things locally we will connect to our local server so go ahead and press Enter and this will accept the defaults.
  • Step 8: Now by default Postgres ships with a database called Postgres so go ahead and also press Enter.
  • Step 9: The default port for Postgres is 5432, so press enter.
  • Step 10: Then the user name is also Postgres so go ahead and press Enter.
  • Step 11: And now remember that previously we added a password so this is when we actually use it so go ahead and use the password that you entered when you installed, press Enter.

And there we go! Now you can see that we are connected to the psql.

Linux users:

  • Step 1: Install PostgreSQL
$ sudo apt-get update 
$ sudo apt-get install postgresql postgresql-contrib
  • Step 2: Connecting to PostgreSQL. In order log into to use Postgres account, we need to give the following command:
$ sudo su — postgres
$ psql

That's it. Your PostgreSQL installation has been completed successfully.

Wait! Do you exactly know what a database is?

If not, then let me tell you, Database is nothing but an organized collection of structured information, or data, typically stored electronically in a computer system. A database is usually controlled by a database management system (DBMS).

List Databases in PostgreSQL Using psql

A single Postgres server process can manage multiple databases at the same time. Each database is stored as a separate set of files in its own directory within the server’s data directory. To view all of the defined databases on the server you can use the \list meta-command or its shortcut \l.

As you can see, we have been given three default databases i.e postgres, template0, and template1.

Cool! Now you are good to go with the Queries.

Throughout this series, we’re not going to be using any graphical user interface client, because I want to show you how production level things work. But instead, we’re going to be using this PSQL.

I’m gonna be using my Linux computer for the entire series. The commands that I’ll show you actually be the exact same for Windows PSQL shell.

This doesn’t end here….

So, we’ve gotten this far with Part 1 of the series: “PostgreSQL- Story of the World’s Most Loved Advances Open Source Database”. Now you are all set to start learning this amazing database. There is still a lot more to cover and learn. So, don’t miss the next article if you want to find out exactly how to deal with PostgreSQL.

Stay tuned for the next post, PART 2.

--

--