DEV Community

Cover image for A Beginner’s Journey with PostgreSQL
Sajjad Rahman
Sajjad Rahman

Posted on

A Beginner’s Journey with PostgreSQL

🧠 PostgreSQL for Those Who Have No Idea!

A real journey from zero to creating your first database — with real logs and beginner mistakes.

“I had no idea how to run PostgreSQL.

I thought, 'Maybe I’ll just install it and it’ll work!'

But once I opened Git Bash, that’s when the real story began…”


💭 The Beginning

Imagine you’re totally new. You’ve just heard — “PostgreSQL is a powerful database.” You install it, but now you’re stuck. How do you actually run this thing?

You type:

psql --version
Enter fullscreen mode Exit fullscreen mode

And PostgreSQL replies:

psql (PostgreSQL) 16.6
Enter fullscreen mode Exit fullscreen mode

Nice! 😍
It’s installed. You feel like a genius already.

But then you try:

psql -U postgres
Enter fullscreen mode Exit fullscreen mode

And suddenly...

password authentication failed for user "postgres"
Enter fullscreen mode Exit fullscreen mode

😬 Uh oh — first roadblock!


Postgressql

🪄 Step 1: Learning from Mistakes

You guess — maybe the password was admin (lol).
You try again:

psql -U postgres
Password for user postgres:
Enter fullscreen mode Exit fullscreen mode

And this time… 🎉

psql (16.6)
Type "help" for help.
postgres=#
Enter fullscreen mode Exit fullscreen mode

You’re in!
Welcome to the PostgreSQL shell 🚀
(Feels a little like hacking in a movie, right?)


🧱 Step 2: What’s Inside This Thing?

Let’s check what databases exist:

\l
Enter fullscreen mode Exit fullscreen mode

PostgreSQL says:

postgres | template0 | template1
Enter fullscreen mode Exit fullscreen mode

So it’s totally empty — a clean slate!


🏦 Step 3: Creating Your First Database

Let’s build your first database — a simple bank 💰

CREATE DATABASE bank;
Enter fullscreen mode Exit fullscreen mode

PostgreSQL replies:

CREATE DATABASE
Enter fullscreen mode Exit fullscreen mode

Now connect to it:

\c bank
Enter fullscreen mode Exit fullscreen mode

Prompt changes:

bank=#
Enter fullscreen mode Exit fullscreen mode

You’re inside your own database now 😎


🧩 Step 4: Creating Your First Table (and Your First Error!)

You try:

CREATE TABLE user(id SERIAL PRIMARY KEY, name VARCHAR(50), balance INT);
Enter fullscreen mode Exit fullscreen mode

But PostgreSQL screams:

ERROR: syntax error at or near "user"
Enter fullscreen mode Exit fullscreen mode

Oops! 😅
Because “user” is a reserved keyword in PostgreSQL.


🧱 Step 5: Renaming the Table and Succeeding

So you fix it:

CREATE TABLE bank_user (
    id SERIAL PRIMARY KEY,
    name VARCHAR(50),
    balance INT
);
Enter fullscreen mode Exit fullscreen mode

This time it works perfectly 🎉

CREATE TABLE
Enter fullscreen mode Exit fullscreen mode

Check your tables:

\dt
Enter fullscreen mode Exit fullscreen mode

Output:

public | bank_user | table | postgres
Enter fullscreen mode Exit fullscreen mode

You did it! ✅


💰 Step 6: Inserting Your First Data

Now add a few users:

INSERT INTO bank_user (name, balance)
VALUES
('Sajjad', 5000),
('Samina', 8000),
('Tanvir', 3000);
Enter fullscreen mode Exit fullscreen mode

PostgreSQL replies:

INSERT 0 3
Enter fullscreen mode Exit fullscreen mode

View your data:

SELECT * FROM bank_user;
Enter fullscreen mode Exit fullscreen mode

Output:

 id |  name  | balance
----+--------+---------
  1 | Sajjad |    5000
  2 | Samina |    8000
  3 | Tanvir |    3000
(3 rows)
Enter fullscreen mode Exit fullscreen mode

💸 Your first mini-bank database is alive!


🔍 Step 7: Exploring the Table

See table structure:

\d bank_user
Enter fullscreen mode Exit fullscreen mode

Output:

Column  | Type | Nullable | Default
--------+------+-----------+-----------------------
id      | int  | not null  | nextval(...)
name    | varchar(50)
balance | int
Enter fullscreen mode Exit fullscreen mode

You’re officially a database architect now 😎


⚙️ Step 8: Let’s Play Around

Want to increase Sajjad’s balance?

UPDATE bank_user SET balance = balance + 2000 WHERE name = 'Sajjad';
Enter fullscreen mode Exit fullscreen mode

Want to delete Tanvir’s account?

DELETE FROM bank_user WHERE name = 'Tanvir';
Enter fullscreen mode Exit fullscreen mode

💬 So Why Learn PostgreSQL?

Because PostgreSQL isn’t just a database —
it’s a way to speak with data.

Learning SQL feels like learning the language that runs the internet.
It’s how every app, website, and system quietly works under the hood.


🧠 Quick Recap

What you did Command
See databases \l
Connect to a DB \c bank
Create table CREATE TABLE bank_user(...);
See tables \dt
Insert data INSERT INTO bank_user ...
View data SELECT * FROM bank_user;
View structure \d bank_user
Quit \q

🌐 Let’s Connect!

If you found this guide helpful, I’d love to hear from you!

Follow or reach out to me on social media 👇

  • 🐙 GitHub – Check out my projects & experiments
  • 💼 LinkedIn – Let’s grow our dev network
  • 🎥 YouTube – Watch tutorials & dev tips
  • 🐦 X (Twitter) – Follow for quick updates & threads

💬 Feel free to comment, share, or drop a question — I’d love to connect with fellow learners and builders!

Top comments (0)