Oracle/user

ROLE

pbj1102 2022. 1. 24. 14:27
반응형

# 롤

1) 롤 생성
SQL> create role hr_pri  ;
Role created.

2) 롤에 권한 부여
SQL> grant create table, create view to hr_pri;
Grant succeeded.

3) 사용자에게 롤 부여
SQL> grant hr_pri to hr;
Grant succeeded.


GRANT DBA,CONNECT, RESOURCE TO  TERAMILLI ;
GRANT PLATFORM, PLATFORM3, FRONT, FRONT3 TO BABOBOX ;




# 확인
? DBA_ROLES:       데이터베이스 존재하는 모든 롤
? DBA_ROLE_PRIVS: 사용지 및 롤에 부여하는 롤
? ROLE_ROL_PRIVS:  롤에 부여하는 롤
? DBA_SYS_PRIVS:   사용자 및 롤에 부여하는 시스템 권한
? ROLE_SYS_PRIVS:  롤에 부여하는 시스템 권한
? ROLE_TAB_PRIVS:  롤에 부여하는 객체 권한
? SESSION_ROLES:   사용자가 현재 활성화한 롤



롤생성

create role pbj_role;


create role pbj_pw_role
identified by pbj;


create role pbj_pw_role_2
identified externally;



EXTERNALLY: 롤을 활성화하기 전에 사용자를 인증해야 함


create role oe_clerk
create role hr_clerk


#롤 수정

alter role oe_clerk
identified by order;


alter role hr_clerk
identified externally


alter role hr_clerk 
not identified;


# 롤 할당

grant oe_clerk to scott;
grant hr_clerk to hr_manager;
grant hr_manager to scott with admin option;



SQL> select *from DBA_ROLE_PRIVS
  2  where grantee='SCOTT';

GRANTEE    GRANTED_ROLE                   ADM DEF
---------- ------------------------------ --- ---
SCOTT      RESOURCE                       NO  YES
SCOTT      OE_CLERK                       NO  YES
SCOTT      HR_MANAGER                     YES YES
SCOTT      CONNECT                        NO  YES







#기본 롤 설정

grant hr_clerk to scott;

alter user scott
default role hr_clerk, oe_clerk;


defualt role < 로그인시 자동으로 활성화 되는 롤



alter user scott default role all;
alter user scott default role all except hr_clerk;
alert user scott default role none;




#롤 활성화 비활성화

set role hr_clerk;

SQL> select * from dba_roles where role = 'HR_CLERK';

ROLE                           PASSWORD AUTHENTICAT
------------------------------ -------- -----------
HR_CLERK                       NO       NONE




set role oe_clerk identified by order;

SQL> select * from dba_roles where role = 'OE_CLERK';

ROLE                           PASSWORD AUTHENTICAT
------------------------------ -------- -----------
OE_CLERK                       YES      PASSWORD






#사용자의 롤 취소

revoke oe_clerk from scott;

SQL> select *from DBA_ROLE_PRIVS where grantee='SCOTT';

GRANTEE    GRANTED_ROLE                   ADM DEF
---------- ------------------------------ --- ---
SCOTT      RESOURCE                       NO  NO
SCOTT      HR_CLERK                       NO  NO
SCOTT      HR_MANAGER                     YES NO
SCOTT      CONNECT                        NO  NO



# 롤 제거

drop role hr_manager;

SQL> select * from dba_roles where role ='HR_MANAGER';

no rows selected













1 데이터 딕셔너리 뷰를 점검하여 RESOURCE 롤의 시스템 권한을 나열하십시오.
select * from role_sys_privs where role='RESOURCE';
select * from dba_sys_privs where grantee = 'RESOURCE';


2 사용자가 테이블 및 뷰를 생성하고 Emi의 CUSTOMERS1 테이블에서 데이터를 선택할
수 있도록 하는 DEV 롤을 생성하십시오.

GRANT CREATE TABLE, create view ,CREATE SESSION TO DEV;
grant select on emi.customers1 to dev;



3 RESOURCE 및 DEV 롤을 Bob에게 할당하되 Bob이 로그온할 때 RESOURCE 롤만
자동 활성화되도록 하십시오.

grant DEV,resource to bob
alter user bob default role resource;






b Bob에게 모든 데이터 딕셔너리 정보를 읽을 수 있는 자격을 부여하십시오.

grant select_catalog_role to bob;





4 Bob은 현재 인스턴스에서 사용되는 실행 취소 세그먼트를 검사해야 합니다.
Bob으로 접속하여 사용되는 실행 취소 세그먼트를 나열하십시오.

힌트: SET ROLE SELECT_CATALOG_ROLE을 사용합니다.


set role select_catalog_role;

select segment_name from dba_rollback_segs where status='ONLINE';

SEGMENT_NAME                   STATUS
------------------------------ ----------------
SYSTEM                         ONLINE
_SYSSMU10_3550978943$          ONLINE
_SYSSMU9_1424341975$           ONLINE
_SYSSMU8_2012382730$           ONLINE
_SYSSMU7_3286610060$           ONLINE
_SYSSMU6_2443381498$           ONLINE
_SYSSMU5_1527469038$           ONLINE
_SYSSMU4_1152005954$           ONLINE
_SYSSMU3_2097677531$           ONLINE
_SYSSMU2_2232571081$           ONLINE
_SYSSMU1_3780397527$           ONLINE








5 SYSTEM 사용자로 연결하여 Emi의 CUSTOMERS 테이블에 CUST_VIEW 뷰를 생성해
보십시오. 결과는?


create view cust_view as select * from emi.customers;

권한 없음







6 Emi 사용자로 접속하여 SYSTEM 사용자에게 CUSTOMERS1에 대한 SELECT 권한을
부여하십시오. SYSTEM 사용자로 접속하여 Emi의 CUSTOMERS1 테이블에 CUST_VIEW
뷰를 생성하십시오. 결과는?


grant select on customers1 to system;
conn system/oracle
create view cust_view as select * from emi.CUSTOMERS1;


반응형

'Oracle > user' 카테고리의 다른 글

synonyms  (0) 2022.01.24
테이블 종류 및 관리  (0) 2022.01.24
PROFILE  (0) 2022.01.24
사용자 권한  (0) 2022.01.24
사용자 관리  (0) 2022.01.24