Javatpoint Logo

91-9990449935

 0120-4256464

PostgreSQL DELETE statement

The DETETE statement is used to delete the existing records from a table. The "WHERE" clause is used to delete the selected records, otherwise all the records would be deleted.

Syntax:

Following is the basic syntax for DELETE statement:

See this example:

Consider a table named "EMPLOYEES" having the following data.

postgre delete1 postgre delete2

Follow the steps given below to delete a table

  • Select table "EMPLOYEES" and right click on that. You will see an option script, move your cursor over scripts, you will see "DELETE script" option. Click on that.
  • You will get a page like this:
  • postgre delete
  • Put the WHERE condition, which you want to delete.

Let's take an example:

Delete records from "EMPLOYEES" where "ID" is 1.

Execute the following query:

postgre delete

Output:

postgre delete

Note:If you don't use "WHERE" condition the whole records will be deleted.

See this example:

postgre delete

Output:

postgre delete