Topic: Database Administration >> data purging
|
Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property.
You may review the entire Oracle Certification Program Candidate Agreement online Here.
|
|
|
|
| black |
Posted: Oct 03, 2007 03:12:46 AM |
Total Post: 14
Joined: Aug, 2007
|
hi friends,
i need data purging scripts.i want to delete the old data.can anybody send me the scripts as soon as possible |
|
|
Billy |
| Posted: Oct 05, 2007 11:51:15 AM | |
|
Total Post: 8
Joined: Jun, 2007
|
The Purging Process permanently deletes the records from a table after a specified period of time. According to my requirement I'll purge the 90 days old records from the table.
The mentioned below Oracle Built-In Packages, Procedures and Jobs will perform the purging tasks.
login With sys;
------------------
1 Create Schedule:
------------------
A schedule defines the frequency and date/time specifics of the start-time for the job.
Begin
dbms_scheduler.create_schedule
(
schedule_name => 'purging_record_schedule',
repeat_interval => 'FREQ=HOURLY; INTERVAL=24',
comments => 'Purge Records after Every 24-Hours'
);
end;
First we create a schedule in which we set the interval parameter which shows the specific time when the Command will execute. In the above schedule the JOB will execute after every 24 hours.
------------------
2 Create JOB:
------------------
A job defines when a specific task and command will be started.
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'purge_interval_job'
,job_type => 'PLSQL_BLOCK'
,job_action => 'BEGIN
Delete from schema.tablename where
ROUND(((sysdate-startdate)*24)/24) >= 90;
COMMIT;
END;'
,schedule_name => 'purging_record_schedule'
,enabled => TRUE
,comments => 'Purge 90 Days Old Records'
);
END;
In the above created job the JOB Action parameter will delete the 90 old day’s records from the table.
-------------------
3 RUN JOB:
-------------------
begin
dbms_scheduler.run_job('purge_interval_job');
end;
--------------------
4 DROP JOB:
--------------------
begin
DBMS_SCHEDULER.DROP_JOB ( job_name => 'purge_interval_job');
end;
Show all jobs and their attributes:
select * from dba_scheduler_jobs;
|
|
|
|
|
| Time Zone: EDT |
Send this thread to your friend |
|
|
|
|
Forum Rules & Description
Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user
|
| |
Get FREE Magazines
|
Top 10 Forum User
|
| Murtuja Khokhar | 814 |
| Mohammed Taj | 694 |
| Jayanta Sur | 479 |
| Vigyan Kaushik | 386 |
| positive fanatic | 361 |
| Gitesh Trivedi | 322 |
| Gopu Gopi | 239 |
| neeraj sharma | 228 |
| Ramesh Jois | 226 |
| snehalatha p | 169 |
|
|