Difference between truncate and delete statements

Difference between truncate and delete statements

Truncate
Truncate is DDL command. It is completely remove the data from the table.
It is fast because does not generate the redo entries and cannot be rollback.
It also reset the high-water mark value for the table.

Example of Truncate table

truncate table employees;

Delete Query
Delete query is used to delete data from the tables. You can use the where clause with it for removing specific or condition based data. Delete statement generate the redo logs.

Delete from table_name [where]

Example of Delete statement

Delete from employees;
delete from employees where id = 100;

Note: Delete without where clause delete all data from the specified table.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.