DEV Community

Kamaleshwar A
Kamaleshwar A

Posted on

PostgreSQL

PostgreSQL:

PostgreSQL is often called Postgres, an open-source relational database management system (RDBMS). The postgreSQL support the standard SQL query and its syntax are similar. This database runs on all major operating systems that contain Linux, UNIX (AIX, BSD, HP-UX, SGI IRIX, Mac OS X, Solaris, Tru64), and Windows. PostgreSQL supports both relational (SQL) and non-relational (JSON) queries.
That stores and manages data in structured tables using SQL.

  • Designed to manage structured data with high reliability and consistency.
  • Supports advanced SQL features, transactions, indexes, and stored procedures.
  • Handles relational, JSON, array, and custom data types efficiently.
  • Used by banking, e-commerce, healthcare, and enterprise applications to manage large volumes of data securely.

CREATE TABLE:

postgres=#  create table car (
  brand Varchar(25),
  model Varchar(25),
  year int
);

CREATE TABLE
Enter fullscreen mode Exit fullscreen mode

INSERT TABLE:

--> Single row inserted in the table.

To insert data into a table in PostgreSQL, we use the INSERT INTO statement.

postgres=# INSERT INTO car (brand, model, year)
VALUES ('Ford', 'Mustang', 1964);

INSERT 0 1
Enter fullscreen mode Exit fullscreen mode

--> Multiple row inserted in the table.

To insert multiple rows of data, we use the same INSERT INTO statement, but with multiple values:

postgres=# INSERT INTO car (brand, model, year)
VALUES
  ('Volvo', 'p1800', 1968),
  ('BMW', 'M1', 1978),
  ('Toyota', 'Celica', 1975); 

INSERT 0 3

Enter fullscreen mode Exit fullscreen mode

DISPLAY THE TABLE:

To check the result we can display the table with this SQL statement:

postgres=# select * from car;
 brand  |  model  | year 
--------+---------+------
 Ford   | Mustang | 1964
 Volvo  | p1800   | 1968
 BMW    | M1      | 1978
 Toyota | Celica  | 1975
(4 rows)

Enter fullscreen mode Exit fullscreen mode

Top comments (0)