Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

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.



  


 Title: data purging
 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

  




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 Khokhar814
  Mohammed Taj694
  Jayanta Sur479
  Vigyan Kaushik386
  positive fanatic361
  Gitesh Trivedi322
  Gopu Gopi239
  neeraj sharma228
  Ramesh Jois226
  snehalatha p169






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software