• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

SQL: Difference between delete and truncate

by admin

This post will discuss the differences between Delete statement and Truncate Statement in Oracle SQL. Understanding this difference will help you to make a better decision in choosing the appropriate statement when a situation arises.

DELETE TRUNCATE
DML Statement DDL statement
Once executed statement changes can be rolledback Auto-commit, once executed changes cannot be rolled back
Conditional DELETE is possible using the WHERE clause TRUNCATE will remove all the data from the table, no conditions can be applied
Performance is less than TRUNCATE, as all the deleted data is copied to the undo tablespace to rollback if required Performance is better than DELETE, as no copying of data to undo tablespace is performed
Does not reset the HVM Resets the HVM, which helps the next queries on the table to execute better
Can be used when a table has Foreign Key  If the table has valid Foreign Key enabled, TRUNCATE command cannot be executed on the table
Any existing DML triggers on a table will be executed when DELETE is fired on a table. Triggers are not executed on issue of a TRUNCATE statement on a table

Filed Under: oracle

Some more articles you might also be interested in …

  1. Understanding Device Persistence and Oracle ASMLib
  2. How to Start/Stop/Relocate SCAN listener in Oracle 11gR2 RAC
  3. How to change the SCAN IP address (SCAN VIP resources) in 11gR2 Grid (CRS) environment
  4. Using Rule Sets in Oracle Database Vault
  5. Sample listener.ora file for Oracle
  6. ORA-16713: The Oracle Data Guard broker command timed out When Changing LogXptMode
  7. ASMLib-Managed Disks on Multipathed iSCSI Targets are not Discovered after Server Reboot in CentOS/RHEL 7
  8. Oracle – How To Check if Autoextensible Datafiles Set To Maxsize Unlimited
  9. Basics of client connectivity in Oracle Data Guard configuration
  10. Beginners Guide to Monitoring SQL Statements with Real-Time SQL Monitoring in Oracle Database

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright