DEV Community

vishwa v
vishwa v

Posted on

Postgresql-1

What is postgresql

PostgreSQL (often called Postgres) is a free, open-source relational database management system.

Itsupports both relational (SQL) and non-relational (JSON) queries.

It stores data in tables with rows and columns, uses the SQL language, and is famous for being very reliable, fast, and safe with data.

Common Uses
Web and Mobile Apps: Powers backend data for dynamic websites.

Financial Systems: Used by banks because it handles money transactions accurately.

Data and AI Workloads: Stores large data sets and works with vector search for AI.

How do you find PostgreSQL Version, Version

select version();
select current_date;
Enter fullscreen mode Exit fullscreen mode
vishwa@vishwa-VivoBook-ASUSLaptop-X421EAY-X413EA:~$ create database cinemas;
Command 'create' not found, did you mean:
  command 'pcreate' from deb pbuilder-scripts (22)
Try: sudo apt install <deb name>
vishwa@vishwa-VivoBook-ASUSLaptop-X421EAY-X413EA:~$ sudo -i -u postgres
[sudo] password for vishwa:             
postgres@vishwa-VivoBook-ASUSLaptop-X421EAY-X413EA:~$ psql
psql (16.14 (Ubuntu 16.14-0ubuntu0.24.04.1))
Type "help" for help.

postgres=# create database cinemasl;
CREATE DATABASE
postgres=# create table movie
postgres-# (
postgres(# movie_name varchar(80)
postgres(# release _date date,
postgres(# ticket int
postgres(# );
ERROR:  syntax error at or near "release"
LINE 4: release _date date,
        ^
postgres=# create table movie
(
movie_name varchar(80)
release _date date,
ticket int
);
ERROR:  syntax error at or near "release"
LINE 4: release _date date,
        ^
postgres=# create table movie
(
movie_name varchar(80),
release_date date,
ticket int
);
CREATE TABLE
postgres=# insert into movie values('jananayagan','2026-07-15', 120);
INSERT 0 1
postgres=# insert into movie (release_date, movie_name, ticket) values ('2025-01-10','sirai', 120);
INSERT 0 1
postgres=# insert into movie(movie_name, ticket) values ('karuppu',120);
INSERT 0 1
postgres=# select * from movie;
 movie_name  | release_date | ticket 
-------------+--------------+--------
 jananayagan | 2026-07-15   |    120
 sirai       | 2025-01-10   |    120
 karuppu     |              |    120
(3 rows)

postgres=# Select movie_name, release_date, ticket*4 as family_price from movie;
 movie_name  | release_date | family_price 
-------------+--------------+--------------
 jananayagan | 2026-07-15   |          480
 sirai       | 2025-01-10   |          480
 karuppu     |              |          480
(3 rows)

Enter fullscreen mode Exit fullscreen mode

Dbms vs RDbms

sql vs nosql
The primary difference is that SQL databases are relational and table-based with fixed schemas, whereas NoSQL databases are non-relational, flexible, and can use document, key-value, graph, or wide-column structures.

postgresql vs mysql

Top comments (0)