Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

PostgreSQL DELETE

removes all records from a table. But this command will not destroy the table's structure
Removing rows can only be done by specifying conditions that the rows to be removed have to match. If you have a primary key in the table then you can specify the exact row. But you can also remove groups of rows matching a condition, or you can remove all rows in the table at once.

--select the table what record do you want to delete
postgres=# select * from demo;                                                  
 id |   name   
----+----------
  2 | benz
  3 | benz
  1 | benz1
  4 | oracle
  5 | mysql
  6 | postgres
  7 | db2
(7 rows)
--You use the DELETE command to remove rows; the syntax is very similar to the UPDATE command
postgres=# delete from demo where id=1;                                         
DELETE 1

postgres=# select * from demo;         
 id |   name   
----+----------
  2 | benz
  3 | benz
  4 | oracle
  5 | mysql
  6 | postgres
  7 | db2
(6 rows)
--Deleting multiple rows in a table
postgres=# delete from demo where id in (2,5,7);
DELETE 3

postgres=# select * from demo;                  
 id |   name   
----+----------
  3 | benz
  4 | oracle
  6 | postgres
(3 rows)
--all rows in the table will be deleted but table structure(metadata) cannot be deleted see following example
postgres=# delete from demo;                    
DELETE 3





Comments

Popular posts from this blog

VMWARE WORKSTATION 3,4,5,6,7,8,9,10,11,12,14,15...etc LICENSE KEYS COLLECTION

PostgreSQL DOMAIN Data Type -2

10. Global Sequences

Oracle to Postgresql migration

How to Configure Oracle Dataguard and How to Perform Switchover and Failover