DEV Community

Cover image for PostgreSQL
Keerthana M
Keerthana M

Posted on

PostgreSQL

PostgreSQL :

  • PostgreSQL is a powerful, open source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads.

why postreSQL?

  • PostgreSQL comes with many features aimed to help developers build applications.
  • Administrators to protect data integrity and build fault-tolerant environments.
  • Help you manage your data no matter how big or small the dataset.
  • In addition to being free and open source, PostgreSQL is highly extensible

Key Features:

  • Open Source
  • ACID Compliant
  • Flexible
  • Extensible

DATABASE:

  • Databases come in various forms, each optimized for specific data structures, workloads, and scalability needs.
  • A database is an organized collection of digital data stored in a computer system.
  • It lets people and apps find, change, and save information fast.

What Does a Database Do?

  • store large amounts of information in one place.
  • find specific records quickly.
  • update data without rewriting everything manually.
  • keep information consistent across applications.
  • control who can access or change important data.

WHAT IS SQL:

  • SQL (Structured Query Language) is the standard language for interacting with Relational Database Management Systems (RDBMS).
  • It allows you to store, retrieve, update, and manage data efficiently and is supported by systems like MySQL, PostgreSQL, SQL Server, and Oracle.

Non-Relational (NoSQL):

  • not only sql
  • Uses flexible formats like documents or key-values instead of rigid tables.
  • Great for messy or fast-changing data.
  • Examples are MongoDB and Firebase.

DIFFERENCE B/W SQL AND NOSQL:

DIFFERENCE B/W DBMS AND RDBMS:

PostgreSQL Installation:

use this command

sudo apt install postgresql postgresql-contrib
Enter fullscreen mode Exit fullscreen mode

to check the status of postgresql is active or not

sudo systemctl status postgresql
Enter fullscreen mode Exit fullscreen mode


sudo -i -u postgres
Enter fullscreen mode Exit fullscreen mode

this command used to run a specific command as the postgres user.

psql
Enter fullscreen mode Exit fullscreen mode

psql is the terminal-based interactive command-line interface for PostgreSQL, allowing you to type, execute, and manage SQL queries and database structures directly.

to create a database

create database cinemas;
Enter fullscreen mode Exit fullscreen mode

use this command to connect database with user

\c cinemas;
Enter fullscreen mode Exit fullscreen mode

to know the version of postgreSQL using this command

select version();
Enter fullscreen mode Exit fullscreen mode

postgresql 16.14

to create a table

create table movie
(
movie_name varchar(80),
release_date date,
ticket int
);
Enter fullscreen mode Exit fullscreen mode

to insert values to a table

insert into movie values('jananayagan','2026-07-15', 120);
Enter fullscreen mode Exit fullscreen mode

to insert a value based on columns name

insert into movie (release_date, movie_name, ticket) values ('2025-01-10','sirai', 120);
Enter fullscreen mode Exit fullscreen mode

we can also insert values without some values

insert into movie(movie_name, ticket) values ('karuppu',120);
Enter fullscreen mode Exit fullscreen mode

to read a table using this command

select * from movie;
Enter fullscreen mode Exit fullscreen mode

Top comments (0)