Search code examples
oracledblink

Scheduling a job in oracle to drop and create table


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

Solution

  • 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.