Pages

How to use SQL DELETE, TRUNCATE, DROP?

DELETE: remove specified rows from a table. You can delete all rows by not writing WHERE statement. It can be undo by ROLLBACK.

DELETE FROM students WHERE studentID IN (10, 20, 30);

TRUNCATE: remove all rows from a table. It can not be undo by ROLLBACK.

TRUNCATE TABLE students; 

DROP: remove table, all indexes and grants over that table. It can not be undo by ROLLBACK.

DROP TABLE students;  

No comments:

Post a Comment