Ridvan EKER’s Weblog – Oracle

September 26, 2007

Drop Objects

Filed under: Datapump — RIDVAN EKER @ 5:00 pm

Drop ‘FUNCTION’,'PACKAGE’,

‘PROCEDURE’,'SEQUENCE’,'SYNONYM’,

‘VIEW’,'TRIGGER’,'TABLE’

 

To be able run this procedure, privilegtes must be given directly to STAGING_DROP_USER

CREATE OR REPLACE PROCEDURE STAGING_DROP_USER.test AS
hand NUMBER ;

cursor c1 is
select object_type, owner, object_name from dba_objects
where object_type in (‘FUNCTION’,'PACKAGE’,'PROCEDURE’,'SEQUENCE’,'SYNONYM’,'VIEW’,'TRIGGER’)
and owner in (select username from dba_users where profile=’SCHEMA’);
r1 c1%rowtype;

–we cannot drop nested tables

cursor c2 is
select owner, table_name from dba_tables where owner in (select username from dba_users where profile=’SCHEMA’)
and table_name not in (select table_name from dba_nested_tables
where owner in (select username from dba_users where profile = ‘SCHEMA’));
r2 c2%rowtype;

BEGIN
– first have to drop plsql and other objects that table_exists_action does not deal with
FOR r1 IN c1 LOOP
execute immediate ‘drop ‘||r1.object_type||’ ‘||r1.owner||’.”‘||r1.object_name||’”‘ ;
END LOOP ;

FOR r2 IN c2 loop
execute immediate ‘drop table ‘||r2.owner||’.”‘||r2.table_name||’” CASCADE CONSTRAINTS PURGE’ ;

END LOOP ;
END ;
/

September 25, 2007

Using 10g datapump and scheduler to copy schemas

Filed under: Datapump — RIDVAN EKER @ 12:27 pm

 

IMP does not owerwrite

‘FUNCTION’,'PACKAGE’,'PROCEDURE’,'SEQUENCE’,

‘SYNONYM’,'VIEW’,'TRIGGER’ (CODE DATABASE)

Import does not replace codes, to be able to create codes only way is to drop related objects or drop and recreate user then start import.

Link below show a way to to this.

P.S: if you have objects created like “object_name” you have to drop them with using quatations

because they are case sensitive.

 

http://andrewfraser.wordpress.com/2007/02/01/using-10g-datapump-and-scheduler-to-copy-schemas/

Blog at WordPress.com.