对操作Oracle数据库的用户进行安全权限控制
一、采用数据库级别触发器控制非sys、system的alter\drop\truncate权限
--控制alter操作
CREATE OR REPLACE TRIGGER SYS.TRIGGER_ALTER
BEFORE ALTER
ON DATABASE
begin
if ora_login_user not in ('SYS','SYSTEM') THEN
Raise_application_error (-20001,'Please not do ALTER!');
end if;
end;
/
BEFORE ALTER
ON DATABASE
begin
if ora_login_user not in ('SYS','SYSTEM') THEN
Raise_application_error (-20001,'Please not do ALTER!');
end if;
end;
/
--控制drop操作
CREATE OR REPLACE TRIGGER SYS.TRIGGER_DROP
BEFORE DROP
ON DATABASE
begin
if ora_login_user not in ('SYS','SYSTEM') THEN
Raise_application_error (-20001,'Please not do DROP!');
end if;
end;
/
BEFORE DROP
ON DATABASE
begin
if ora_login_user not in ('SYS','SYSTEM') THEN
Raise_application_error (-20001,'Please not do DROP!');
end if;
end;
/
--控制truncate操作
CREATE OR REPLACE TRIGGER SYS.TRIGGER_truncate
BEFORE truncate
ON DATABASE
begin
if ora_login_user not in ('SYS','SYSTEM') THEN
Raise_application_error (-20001,'Please not do TRUNCATE!');
end if;
end;
/
CREATE OR REPLACE TRIGGER SYS.TRIGGER_truncate
BEFORE truncate
ON DATABASE
begin
if ora_login_user not in ('SYS','SYSTEM') THEN
Raise_application_error (-20001,'Please not do TRUNCATE!');
end if;
end;
/
经过测试,一般用户进入数据库后无法进行alter、drop、truncate的操作
限制了对数据的破坏性操作,若进行上述操作,系统会产生
ORA-00604: error occurred at recursive SQL level 1
ORA-20001: Please do not DROP!
ORA-20001: Please do not DROP!
之类错误
PS:未限制create操作,因为1、create操作不会对生产数据产生破坏性影响;
2、若限制create操作,可能会导致create index的操作失败
======================================================
二、调整tssa用户权限
REVOKE "DBA" FROM "TSSA";
GRANT "CONNECT" TO "TSSA";
GRANT "CONNECT" TO "TSSA";
将dba权限从tssa用户移除,并重新对其赋予connect权限
经过业务测试,未发现引起业务异常
=======================================================
三、创建只读用户bzwh
CREATE USER "BZWH" PROFILE "DEFAULT"
IDENTIFIED BY "bzwh" DEFAULT TABLESPACE "USERS"
ACCOUNT UNLOCK;
GRANT CREATE SESSION TO "BZWH"
GRANT SELECT ANY DICTIONARY TO "BZWH"
GRANT SELECT ANY SEQUENCE TO "BZWH"
GRANT SELECT ANY TABLE TO "BZWH"
相关推荐
Hody 2020-08-16
FightFourEggs 2020-08-16
yanghuatong 2020-08-16
娜娜 2020-06-22
zhangchaoming 2020-06-04
FightFourEggs 2020-05-28
LuoXinLoves 2020-08-09
Justdoit00 2020-06-26
Carlos 2020-06-16
Carlos 2020-05-26
流云追风 2020-05-14
Kingonion 2020-05-04
langyue 2020-05-03
zjyhll 2020-04-26
oraclemch 2020-04-19
learningoracle 2020-04-18