What is the difference among “dropping a table”, “truncating a table” and “deleting all records” from a table.

Drop Table - will remove the existance of the table from the database along with its data and structure and all the constraints. The table will be no longer available. This is an DDL Statement.

Truncate Table - will remove all the rows from a table. It will not delete the table. Its a DDL statement that means the deleted rows cannot be reverted back by ROLLBACK statement. It will only be used if users needs to delete the entire rows from a tabls. No conditions will be applied in Truncate.

Delete Table - is a DML statement which will delete rows from a table according to the matching criteria mentions in the ‘where’ clause and these rows can be reverted back by ‘ROLLBACK’ statement if ‘COMMIT’ is not fired. Delete statement will used in both the cases, eitehr selected rows or entire rows from tables.

No comments:

topics