In this Section, We will explore about the Difference between Delete and Truncate in Oracle SQL.
We have different-different SQL command to delete or remove data from Oracle database table. Today we will discuss that SQL command which is that Delete and Truncate commands. What is Delete Command in Oracle?Delete is a DML command. Delete Command is used to remove specific rows from the table by using WHERE clause and Delete Command also helps to remove all rows from the table. Syntax of Delete CommandDelete from Table_Name [Where condition]; Example of Delete CommandDELETE FROM ADD_CART WHERE PRODUCT_ID=7; Let's understand about the above statement, I have table which name is ADD_CART and I am removing rows where product_id will be 7. What is Truncate Command?Truncate is a DDL command. This command is use for the remove all records from the table. We can't use the Where clause in truncate command. Syntax of TruncateTruncate table Table_Name; Example of TruncateTRUNCATE table ADD_CART; Difference Between Delete and Truncate in OracleDelete Command
Truncate Command
Conclusion:- Based on requirements you can select your way that which way is necessary for your requirements. Delete is mostly used for remove specific rows from the table while Truncate Command is use for remove all rows from the table. Note:- Run Following SQL Query to check table space size. (select segment_name,sum(bytes)/1024/1024/1024 GB from dba_segments where segment_type='TABLE' and segment_name=upper('table_name') group by segment_name; ) That's all for today, I think (Basic Difference Between Delete And Truncate in Oracle SQL) post will helpful for you. If you like this post then share your view in the comment box. |
0 Comments
If you have any doubts, Please let me know