0% found this document useful (0 votes)
2 views8 pages

Introduction To PostgreSQL Database

yo

Uploaded by

anuraggameslpu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views8 pages

Introduction To PostgreSQL Database

yo

Uploaded by

anuraggameslpu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Introduction to PostgreSQL Database

PostgreSQL is a powerful, open-source


relational database management system
(RDBMS) used to store, manage, and retrieve
data efficiently.
🔹 Key Features
• Open Source (free to use)
• Supports SQL (Structured Query
Language)
• Highly reliable and secure
• Supports ACID properties (Atomicity,
Consistency, Isolation, Durability)
• Advanced features like:
o JSON support

o Indexing

o Triggers

o Stored procedures

• Cross-platform (Windows, macOS, Linux)


• • Supports complex queries
• • ACID compliant (reliable transactions)
• • Used by companies like Apple,
• Instagram, Uber

🔹 Why Use PostgreSQL?


• Handles large-scale applications
• Strong data integrity
• Widely used in web, enterprise, and
analytics systems

🔹 PostgreSQL stores data as:


Server → Database → Schema →
Tables → Rows & Columns

PostgreSQL Installation
✅ 1. Installation on Windows
Steps:
[Link] to official website:
👉
[Link]
dows/
[Link] installer from EnterpriseDB
[Link] the installer and follow steps:
o Select installation directory

o Choose components (pgAdmin,

PostgreSQL Server)
o Set password for superuser

(postgres)
o Choose port (default: 5432)

[Link] installation

🔹 Steps (macOS / Windows / Linux)


[Link] PostgreSQL from official site
[Link] PostgreSQL server
[Link] pgAdmin 4 (GUI tool)
[Link] password for postgres user
[Link] installation using:
psql –version

🔹 Tools after installation


• pgAdmin 4 → Graphical interface
• psql → Command-line interface

🚀 How to Work with pgAdmin 4 (Beginner


Guide)
1⃣ Add / Connect to PostgreSQL Server
(First Time)
On the screen you shared, click:

👉 Add New Server

🔹 General Tab
• Name:
• Local PostgreSQL

🔹 Connection Tab
Fill these exactly:
Field Value
Host name /Address localhost
Port 5432
Maintenance database postgres
Username postgres

Field Value
Password 🔐 (the password you set
during installation)
Save password ✅ Check
Click Save

Open Query Tool Workspace and provide


the details and then continue..

CRUD Commands:

1. Create a New Database

Run this in Query Tool (connected to


postgres database):
CREATE DATABASE studentdb;

✅ Success message = database created


✅ Create a table (correct SQL)
Now run:

CREATE TABLE students (


id SERIAL PRIMARY KEY,
name VARCHAR(100),
course VARCHAR(50),age INT
);

✅ Insert data

INSERT INTO students (name,


course, age)
VALUES ('Komal', 'Computer
Science', 21);

INSERT INTO students (name,


course, age)
VALUES ('Amit', 'Science', 25);
✅ View data

SELECT * FROM students;

🔄 UPDATE Command
🔹 Example 1: Update course for id = 1
UPDATE students
SET course = 'IT'
WHERE id = 1;

Example 2: Update multiple columns


UPDATE students
SET name = 'Rahul', course =
'Engineering'
WHERE id = 1;

❌ DELETE Command
🔹 Example 1: Delete specific row
DELETE FROM students
WHERE id = 1;

🔹 Example 3: Delete all records


DELETE FROM students;
👉 Table structure remains, only data deleted

🗑 DROP DATABASE Command

DROP DATABASE Studentdb;

Then check:
\l or \list
👉 If you don’t see Studentdb → ✔ Done

You might also like