0% found this document useful (0 votes)
20 views2 pages

PostgreSQL Basics PDF Guide

PostgreSQL is an open-source, object-relational database management system known for its reliability and advanced SQL features. It supports various data types and commands for database management, including creating, connecting, and manipulating tables. Key advantages include cross-platform compatibility, ACID compliance, and a strong community for support.

Uploaded by

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

PostgreSQL Basics PDF Guide

PostgreSQL is an open-source, object-relational database management system known for its reliability and advanced SQL features. It supports various data types and commands for database management, including creating, connecting, and manipulating tables. Key advantages include cross-platform compatibility, ACID compliance, and a strong community for support.

Uploaded by

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

PostgreSQL Basics

1. What is PostgreSQL?
PostgreSQL is an open-source, object-relational database management system (ORDBMS). It
is known for reliability, ACID compliance, and advanced SQL features. It supports both SQL
(relational) and JSON (non-relational) querying.

2. Key Features
 Cross-platform: Works on Windows, Linux, macOS
 ACID compliant: Ensures safe transactions
 Advanced indexing: B-Tree, Hash, GIN, GiST, BRIN
 Full-text search support
 Extensibility: Define custom data types, operators, and functions
 MVCC (Multi-Version Concurrency Control) for high-performance concurrent
operations

3. Common Data Types


 Numeric: INTEGER, SERIAL, BIGINT, NUMERIC, REAL
 Text: CHAR, VARCHAR, TEXT
 Date/Time: DATE, TIME, TIMESTAMP
 Boolean: BOOLEAN
 JSON/Array: JSON, JSONB, ARRAY

4. Basic Commands

-- Create a Database
CREATE DATABASE college_db;

-- Connect to a Database
\c college_db;

-- Create a Table
CREATE TABLE students (
student_id SERIAL PRIMARY KEY,
name VARCHAR(50),
age INT,
department VARCHAR(50)
);

-- Insert Data
INSERT INTO students (name, age, department)
VALUES ('John Doe', 20, 'Computer Science');
-- Select Data
SELECT * FROM students;

-- Update Data
UPDATE students SET age = 21 WHERE student_id = 1;

-- Delete Data
DELETE FROM students WHERE student_id = 1;

5. PostgreSQL Tools
 psql – Command-line interface
 pgAdmin – GUI for managing PostgreSQL
 libpq – C library for connecting applications

6. Advantages
 Open-source and free
 Rich set of functions
 High security with role-based access
 Large community and strong documentation

You might also like