Deleting Rows
The Deleting Rows section describes the following:
Deleting Selected Rows
You can delete rows in a table selectively using the DELETE
command. You must include a table name and a WHERE
clause to specify the rows to delete, as shown in the following example:
test=> DELETE FROM cool_animals WHERE weight is null;
executed
master=> SELECT * FROM cool_animals;
1,Dog ,7
2,Possum ,3
3,Cat ,5
4,Elephant ,6500
5,Rhinoceros ,2100
5 rows
Deleting All Rows
You can delete all rows in a table using the TRUNCATE
command followed by the table name, as shown in the following example:
test=> TRUNCATE TABLE cool_animals;
executed
Note
While using the TRUNCATE command will both delete rows from a table and physically remove data from your disk, using the DELETE command will logically delete rows from a table. To remove data from your disk after using the DELETE
command, use CLEAN UP.
For more information, see the following: