nrajasekhar7
asked on
How to use a Commit when we are deleting the Large amont of data
Hi
We are using the Oracle 10g database ,We are using the Script to delete the data older than six months, if it fails for one table than everything Rollbacks,
How to use commit command in between so that after deleting few tables it can commit in between.or can we use the commit command for each each table .
Please suggest asasp!!
Thanks in advance
Raj.
We are using the Oracle 10g database ,We are using the Script to delete the data older than six months, if it fails for one table than everything Rollbacks,
How to use commit command in between so that after deleting few tables it can commit in between.or can we use the commit command for each each table .
Please suggest asasp!!
Thanks in advance
Raj.
Depending of size of tables and number of rows to delete, this task become complex as you need take care about redo log size, time to delete ...
If the size is aceptable, do one commit only as some table information can be related to other tables.
Include a Whenever sentence to do roolback.
WHENEVER SQLERROR {EXIT [SUCCESS | FAILURE | WARNING | n | variable | :BindVariable] [COMMIT | ROLLBACK] | CONTINUE [COMMIT | ROLLBACK | NONE]}
If the size is aceptable, do one commit only as some table information can be related to other tables.
Include a Whenever sentence to do roolback.
WHENEVER SQLERROR {EXIT [SUCCESS | FAILURE | WARNING | n | variable | :BindVariable] [COMMIT | ROLLBACK] | CONTINUE [COMMIT | ROLLBACK | NONE]}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you are using proper foreign keys. Then you use the on delete cascade clause so if any dependency it will automatically cater it otherwise you can rollback. Depending upon the average data being deleted you can provide the commit within the iteration likewise.
You can use Truncate which doesn't need a Commit.
Truncate Table1;
Truncate Table2;
etc...
You cannot roll-back from a Truncate.
Truncate Table1;
Truncate Table2;
etc...
You cannot roll-back from a Truncate.
Add exception handling to your code block which has delete statements and handle the exception/error and do a commit in the exception section.
- or in your script, you can put a commit after each table delete operation eg:
delete tablename1 where ... ;
commit;
delete tablename2 where ... ;
commit;