以system用户登录数据库,创建trigger,以实现禁止test用户登录执行alter,drop,truncate test.objects:
--connected as system user
CREATE OR
REPLACE
TRIGGER
trig_prevent_ddl
BEFORE
ALTER
OR
DROP
OR
TRUNCATE
ON
test.SCHEMA
BEGIN
raise_application_error (num => -20000,
msg => 'Cannot
alter,drop,truncate object'
);
END;
/
此时system用户可以执行alter,drop,truncate test.objects:
SQL> truncate table test.test2;
Table truncated.
以test用户登录数据库
--connected as test user
SQL> truncate table test2;
truncate table test2
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-20000: Cannot alter,drop,truncate object
ORA-06512: at line 2