为 "Not allow any other connection into database other than user having DBA priviledge" 创建触发器
create trigger for "Not allow any other connection into database other than user having DBA priviledge"
我想创建一个触发器,但我必须为此创建触发器
Not allow any other connection into database other than user having DBA priviledge
实施这种限制的正确方法是 运行
ALTER SYSTEM ENABLE RESTRICTED SESSION;
这会阻止非 DBA 连接到数据库。
但是,由于练习是实现触发器,因此解决方案可能是这样的:
CREATE OR REPLACE TRIGGER T_LOGON
AFTER LOGON ON DATABASE
BEGIN
IF not DBMS_SESSION.IS_ROLE_ENABLED('DBA') THEN
raise_application_error(-20001, 'You are not permitted to logon');
end if;
END;
/
实际上你可以让它更短:
CREATE OR REPLACE TRIGGER T_LOGON
AFTER LOGON ON DATABASE
BEGIN
raise_application_error(-20001, 'You are not permitted to logon');
END;
/
因为作为 DBA
,您拥有特权 ADMINISTER DATABASE TRIGGER
,这允许您登录,而不管登录触发器作为故障保护抛出的错误。
我想创建一个触发器,但我必须为此创建触发器
Not allow any other connection into database other than user having DBA priviledge
实施这种限制的正确方法是 运行
ALTER SYSTEM ENABLE RESTRICTED SESSION;
这会阻止非 DBA 连接到数据库。
但是,由于练习是实现触发器,因此解决方案可能是这样的:
CREATE OR REPLACE TRIGGER T_LOGON
AFTER LOGON ON DATABASE
BEGIN
IF not DBMS_SESSION.IS_ROLE_ENABLED('DBA') THEN
raise_application_error(-20001, 'You are not permitted to logon');
end if;
END;
/
实际上你可以让它更短:
CREATE OR REPLACE TRIGGER T_LOGON
AFTER LOGON ON DATABASE
BEGIN
raise_application_error(-20001, 'You are not permitted to logon');
END;
/
因为作为 DBA
,您拥有特权 ADMINISTER DATABASE TRIGGER
,这允许您登录,而不管登录触发器作为故障保护抛出的错误。