Delete is a DML (Data Manipulation Language) command where as Truncate and DROP are DDL (Data Definition Language) commands.
Three are used to remove rows from the table, but there are few differences
If we use Delete on any table, all rows in that table are deleted, but it doesn't free the space containing the table.
Ex: DELETE FROM TABLE_NAME WHERE CONDITION
If 'where' condition is not specified in the above example, all the rows in the corresponding table are deleted.
Truncate is also used to delete the rows from the table, but it frees the space containing the table
Ex: TRUNCATE TABLE TABLE_NAME
Drop is used to delete the entire table including rows, privileges, relationships with other tables.
Ex: DROP TABLE TABLE_NAME
Delete operation can be rolled back (B'coz Delete is a DML command), where as Truncate and drop operations can't be rolled back (B'coz these two are DDL commands).
No comments:
Post a Comment