CRUD Operations in PostgreSQL
CRUD stands for:
C: Create (Insert)
R: Read (Select)
U: Update
D: Delete
This section introduces the commands to perform each of these operations on PostgreSQL tables.
Insert operation:
It is used to insert entries into the database relations (tables).
Syntax:
insert into table_name
(column1,
column2,
----
columnN)
values (value1, value2, value3, ___ valueN);

For inserting multiple rows together, we specify the values for each row, separated by commas as follows:

Select operation:
The select operation is used to retrieve specific data from the database.
Syntax:
select
column1,
column2,
----
columnN
from table_name;
To select values from all columns, we can use * instead of writing all columns.
Update operation:
The update operation lets one update the already existing data in the database.
Syntax:
update table_name
set
column1 = value1,
column2 = value2,
----
columnN = valueN
where
condition;
The where clause is used to specify the condition that must be satisfied by the rows whose column values need to be updated.

Delete operation:
The delete command is used to delete existing records (rows) that satisfy the given condition (specified using where clause) from the table.
Syntax:
delete from table_name
where [condition];

If no condition is specified, then all the rows of the table get deleted.

1
