Truncate in DB2: It deletes all the rows from a table
TRUNCATE TABLE INVENTORY
IGNORE DELETE TRIGGERS;
Delete in DB2:
DELETE FROM TABLE TABLE_ONE;
It also deletes rows from a table
Differences between TRUNCATE and DELETE
- you can use following command which will perform same operation as truncate in DB2 “Alter table table_name activate not logged initially with empty table”. Logging will not happen in this command, while in delete logging will be done.
- You can’t rollback in this kind of truncate and you can rollback in delete.
- No triggers are fired in alter table command, while delete command will fire triggers.
- You can specify where clause in this alters table command
- You can’t use conditions (WHERE clause) in TRUNCATE. But in DELETE you can write conditions using WHERE clause