PostgreSQL Delete Table

Delete is data manipulation command. Delete will removes the rows from a table. It will remove all rows from a table. If we specify the where clause, then it removes only matched records.

Syntax:

[ WITH [ RECURSIVE ] with_query [, …] ]
DELETE FROM [ ONLY ] table_name [ * ] [ [ AS ] alias ]
[ USING using_list ]
[ WHERE condition | WHERE CURRENT OF cursor_name ]
[ RETURNING * | output_expression [ [ AS ] output_name ] [, …] ]

Examples:

Create table as shown in PostgreSQL Create Table
Insert data as shown in PostgreySQL insert command

As per above example, student table contains following rows
postgresql delete table

Delete the rows whose date of birth(dob) is older than year 2015.

delete student where dob<'01-01-2015'

postgresql-delete-table1

Powered by k2schools