quarta-feira, 25 de novembro de 2009

Dropando objetos de um usuário

Normally, it is simplest to drop and add the user. This is the preferred method if you have system or sysdba access to the database.

If you don't have system level access, and want to scrub your schema, the following sql will produce a series of drop statments, which can then be executed.

 
1.
2.
3.
select 'drop '||object_type||' '|| object_name||  
DECODE(OBJECT_TYPE,'TABLE',' CASCADE CONSTRAINTS;',';')
from user_objects
 


Then, I normally purge the recycle bin to really clean things up. To be honest, I don't see a lot of use for oracle's recycle bin, and wish i could disable it... but anyway:


1.
purge recyclebin;
 


This will produce a list of drop statements. Not all of them will execute - if you drop with cascade, dropping the PK_* indices will fail. But in the end, you will have a pretty clean schema.
Confirm with:

1.
select * from user_objects


0 comentários:

Postar um comentário