Wednesday, 8 July 2015

Clear SDE schema from tables of dropped schemas

delete from column_registry
where OWNER in ('FLEET_V1','GIS_B','ATLAS_V1', 'GIS_V1', 'GIS','gis', 'GIS_CODING', 'GIS_TEST', 'GIS_C', 'gis_c', 'GIS_D', 'gis_d'  );

delete from GEOMETRY_COLUMNS
where F_TABLE_SCHEMA in ('FLEET_V1','GIS_B','ATLAS_V1', 'GIS_V1', 'GIS','gis', 'GIS_CODING', 'GIS_TEST', 'GIS_C', 'gis_c', 'GIS_D', 'gis_d'  );

delete from LAYERS
where OWNER in ('FLEET_V1','GIS_B','ATLAS_V1', 'GIS_V1', 'GIS','gis', 'GIS_CODING', 'GIS_TEST', 'GIS_C', 'gis_c', 'GIS_D', 'gis_d' );

delete from GDB_ITEMS
where NAME like 'FLEET_V1%' or NAME like'GIS_B%' or NAME like'ATLAS_V1%' or  NAME like'GIS_V1%' or NAME like'GIS%' or NAME like'GIS_CODING%'
or NAME like'gis_c%' or NAME like'gis_d%' or NAME like'gis%' or NAME like'GIS_D%' ;

COMMIT;

DROP USER gis_d CASCADE;
DROP USER gis_c CASCADE;
DROP USER gis_test CASCADE;
DROP USER gis CASCADE;


DECLARE
  match_count integer;
  v_search_string varchar2(4000) := 'fff';
BEGIN  
  FOR t IN (SELECT owner, table_name, column_name FROM all_tab_columns) LOOP   
    EXECUTE IMMEDIATE    
      'SELECT COUNT(*) FROM '||t.owner || '.' || t.table_name||
      ' WHERE '||t.column_name||' = :1'   
       INTO match_count  
      USING v_search_string; 
    IF match_count > 0 THEN 
      dbms_output.put_line( t.owner || '.' || t.table_name ||' '||t.column_name||' '||match_count );
    END IF; 
  END LOOP;
END;

No comments:

Post a Comment