Sunday, January 9, 2011

Difference between DELETE and TRUNCATE


Delete command removes rows based on the criteria which we define on Where clause.
Truncate removes all the rows from the table.
Syntax for Delete:
DELETE FROM tablename WHERE column_name <op> value
ex.
DELETE FROM employee where EMPID>10
it will removes all the employee havind EMPID is greater than 10.
Syntax for TRUNCATE:
TRUNCATE TABLE tablename
ex.
TRUNCATE TABLE employee
it will remove all the records from employee table:
Similarity:
delete from employee
is similar to
truncate table employee

No comments:

Post a Comment