The DELETE statement is used to delete rows in a table.
Delete All Data
Query :
delete from tablename
Example :
delete from empdetails
Delete Particular Row - using Where clause
Query :
delete from tablename where columnname = value
Example :
delete from empdetails where id = 1
Be very careful when deleting records. You cannot undo this statement!
Tuncating a Table
The TRUNCATE statement is used to removes all rows from a table. The operation cannot be rolled back and no triggers will be fired. As such, TRUCATE is faster and doesn't use as much undo space as a DELETE.
Query :
truncate table tablename
Example :
truncate table empdetails.
This comment has been removed by the author.
ReplyDeletewhen can i use truncate
ReplyDeleteTRUNCATE removes all rows from a table. The operation cannot be rolled back and no triggers will be fired. As such, TRUCATE is faster and doesn't use as much undo space as a DELETE.
DeleteWe cannot use Where Clause in TRUNCATE .