2

I am trying to DROP and CREATE a table using a scheduled job. How to do it please?

DROP TABLE REGISTRATION;

CREATE TABLE REGISTRATION AS
SELECT *
FROM REGISTRATION_MV@D3PROD_KMDW
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
FatherofFaris
  • 41
  • 1
  • 5

3 Answers3

2

perhaps you are looking for a materialized view instead of the table?

create materialized view registration as
select *
from registration_mv@d3prod_kmdw

and then refresh it in job

dbms_mview.refresh('REGISTRATION');

This is much better than dropping and creating the table because PL/SQL objects will become invalid after dropping the table. With mview it will be silent and without harm.

smnbbrv
  • 23,502
  • 9
  • 78
  • 109
  • I agree. Although, technically this is not the answer for the question asked, it is highly probable that this is what Neels wants. Maybe (s)he'd like to elaborate. – René Nyffenegger Feb 17 '14 at 10:03
1

You should use DBMS_SCHEDULER to schedule jobs in Oracle.

Refer to the documentation for how to create a sample scheduler job

Incognito
  • 2,964
  • 2
  • 27
  • 40
1

Don't drop and recreate the table. If you do this on a regular basis you will end up with a huge number of items in your recycle bin, which can lead to problems. Also as above you can invalidate pl/sql when you drop objects, and can break your app if they fail to recompile.

Instead you should truncate the table to delete all rows, and then repopulate it:

truncate table registration;

insert into registration (select * from registration_mv@D3PROD_KMDW);

Community
  • 1
  • 1
Andrew Brennan
  • 333
  • 1
  • 9