DELETE:
The DELETE command is used
to remove rows from a table. A WHERE clause can be used to only remove some
rows. If no WHERE condition is specified, all rows will be removed. After
performing a DELETE operation you need to COMMIT or ROLLBACK the transaction to
make the change permanent or to undo it. Note that this operation will cause
all DELETE triggers on the table to fire.
SQL> SELECT COUNT(*) FROM emp;
COUNT(*)
----------
14
SQL> DELETE FROM emp WHERE job = 'CLERK';
4 rows deleted.
SQL> COMMIT;
Commit complete.
SQL> SELECT COUNT(*) FROM emp;
COUNT(*)
----------
10
TRUNCATE:
When you TRUNCATE a table, it eliminates all of the rows in
it. In addition, there will be no triggers activated as a result of the
procedure. Consequently, TRUNCATE is both quicker and uses less undo space than
DELETE when compared to the former.
SQL> TRUNCATE TABLE emp;
Table truncated.
SQL> SELECT COUNT(*) FROM emp;
COUNT(*)
----------
0
DROP:
The DROP command is used to completely delete a table from
the database. All of the rows, indexes, and privileges associated with the
tables will be erased as well. There will be no DML triggers triggered. It is
not possible to undo the previous operation.
SQL> DROP TABLE emp;
Table dropped.
SQL> SELECT * FROM emp;
SELECT * FROM emp
*
ERROR at line 1:
ORA-00942: table or view does not exist
In contrast to DELETE, which is a DML action, DROP and
TRUNCATE are DDL commands. The result is that deletions may be rolled back
(undone), but deletions of data from DROP and TRUNCATE files cannot be reverted
back.
A table may be "un-dropped" starting with Oracle
10g. Example:
SQL> FLASHBACK TABLE emp TO BEFORE DROP;
Flashback complete.
In contrast to DELETE, which is a DML action, DROP and
TRUNCATE are DDL commands. The DELETE action, on the other hand, may be
reverted (undone), but the DROP and TRUNCATE procedures cannot be reverted
(undone).
I hope it's helpful for you. If you have any queries, don't hesitate to contact me.
0 comments:
Post a Comment
If you have any doubts, please let me know. I will help you.