Monday, August 18, 2014

Restrict the DROP command in a SCHEMA object in a DATABASE

Restrict the DROP the SCHEMA object in a DATABASE


Create Or Replace Trigger AvoidSchemaDrop
Before Drop On Database
Declare
    BEGIN
     If Ora_Dict_Obj_Name  In ('UK')   
    THEN
        Raise_Application_Error(-20015,'Schema or User '||Ora_Dict_Obj_Name ||' Cannot be dropped!'); 
    END IF;
End;
/
Trigger created.



You can change the schema names (marked in Red) as per your requirement.
SQL>drop user sthomas;
drop user sthomas
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-20015: Schema or User STHOMAS Cannot be dropped!
ORA-06512: at line 5




No comments:

Post a Comment