begin
  for cur in (select fk.owner, fk.constraint_name , fk.table_name 
    from all_constraints fk, all_constraints pk 
     where fk.CONSTRAINT_TYPE = 'R' and 
           pk.owner = 'TASY' and
           fk.r_owner = pk.owner and
           fk.R_CONSTRAINT_NAME = pk.CONSTRAINT_NAME and 
           pk.TABLE_NAME = 'APP_HOST') loop
    execute immediate 'ALTER TABLE "'||cur.owner||'"."'||cur.table_name||'" MODIFY CONSTRAINT "'||cur.constraint_name||'" DISABLE';
  end loop;
end;
/

begin
  for cur in (select fk.owner, fk.constraint_name , fk.table_name 
    from all_constraints fk, all_constraints pk 
     where fk.CONSTRAINT_TYPE = 'R' and 
           pk.owner = 'TASY' and
           fk.r_owner = pk.owner and
           fk.R_CONSTRAINT_NAME = pk.CONSTRAINT_NAME and 
           pk.TABLE_NAME = 'APP_IMAGE') loop
    execute immediate 'ALTER TABLE "'||cur.owner||'"."'||cur.table_name||'" MODIFY CONSTRAINT "'||cur.constraint_name||'" DISABLE';
  end loop;
end;
/

truncate table tasy.APP_REMOTE_LOG;
truncate table tasy.APP_REMOTE_INFO;
truncate table tasy.APP_REMOTE_ACTIONS;
truncate table tasy.APP_MANAGER_VERSION_BLOCK;
truncate table tasy.APP_IMAGE_DEPENDENT;
truncate table tasy.APP_IMAGE;
truncate table tasy.APP_HOST_STATUS;
truncate table tasy.APP_HOST;
truncate table tasy.APP_DB_STATUS;
truncate table tasy.APP_CUSTOM_FILE;
truncate table tasy.APP_CONTAINER;
truncate table tasy.APP_CONFIG;




begin
  for cur in (select fk.owner, fk.constraint_name , fk.table_name 
   from all_constraints fk, all_constraints pk 
    where fk.CONSTRAINT_TYPE = 'R' and 
          pk.owner = 'TASY' and
          fk.r_owner = pk.owner and
          fk.R_CONSTRAINT_NAME = pk.CONSTRAINT_NAME and 
          pk.TABLE_NAME = 'APP_HOST') loop
    execute immediate 'ALTER TABLE "'||cur.owner||'"."'||cur.table_name||'" MODIFY CONSTRAINT "'||cur.constraint_name||'" ENABLE';
  end loop;
end;
/

begin
  for cur in (select fk.owner, fk.constraint_name , fk.table_name 
   from all_constraints fk, all_constraints pk 
    where fk.CONSTRAINT_TYPE = 'R' and 
          pk.owner = 'TASY' and
          fk.r_owner = pk.owner and
          fk.R_CONSTRAINT_NAME = pk.CONSTRAINT_NAME and 
          pk.TABLE_NAME = 'APP_IMAGE') loop
    execute immediate 'ALTER TABLE "'||cur.owner||'"."'||cur.table_name||'" MODIFY CONSTRAINT "'||cur.constraint_name||'" ENABLE';
  end loop;
end;
/

alter system set job_queue_processes=1000 scope=both;
grant select on V_$INSTANCE to tasy;
grant select on GV_$INSTANCE to tasy;
grant select on V_$SQLTEXT to tasy;
grant select on GV_$SQLTEXT to tasy;
grant select on V_$OPTION to tasy;
grant select on GV_$OPTION to tasy;
