TECH
QUESTION
자주하는 질문답변 입니다.
Oracle
작성자 | 유건데이타 | 등록일 | 2015-05-14 |
제목 | 권한주기 스크립트 생성 | ||
---|---|---|---|
권한주기 스크립트 생성
권한주기 스크립트 생성 ====================== 예제> scott 유저의 모든 table을 select 할 수 있는 권한을 scott_role에 부여하는 sql생성하기 SQL> set head off SQL> set verify off SQL> set term off SQL> spool grant.sql SQL> select 'grant select on '||table_name||' to scott_role;' 2 from user_tables; grant select on TEST to scott_role; grant select on EMP_FOR to scott_role; grant select on EMP to scott_role; grant select on DEPT to scott_role; grant select on BONUS to scott_role; grant select on SALGRADE to scott_role; grant select on DUMMY to scott_role; grant select on BIG_TABLE to scott_role; grant select on BIG_TABLE2 to scott_role; grant select on SYS_TEMP_FBT to scott_role; 10 rows selected. SQL> spool off SQL> SQL>@grant.sql 객체 권한 주는 것 입니다. 오브젝 권한 테이블 : alter, delete, index, insert, references, select, update (execute를 제외한 모두) 뷰 : delete, insert, select, update 시퀀스 : alter, select 프로시저 : execute ######## example sql> conn scott/tiger sql> create table emp1 (a number); sql> grant select on emp1 to kopuk; sql> grant update on emp1 to kopuk; sql> grant delete on emp1 to kopuk; sql> grant all on emp1 to kopuk; ### all 키워드로 한번에 다주기 sql> conn kopuk/kopuk sql> select * from scott.kopuk; ####### role로 생성해서 주기 sql> conn system/manager sql> grant create role to scott; ## 시스템 권한 주기 sql> conn scott/tiger sql> create role emp_role; sql> grant select on emp to emp_role; sql> grant update on emp to emp_role; sql> grant delete on emp to emp_role; sql> grant insert on emp to emp_role; sql> grant emp_role to salary; ## with grant option 으로 다른 사용자에게 객체 권한 주기 sql> conn scott/tiger sql> grant select on emp1 to kopuk; sql> grant select on emp1 to kopuk with grant option; sql> conn kopuk/kopuk sql> grant select on scott.emp1 to system; ##### 시스템 권한 주기 ################## sql> grant create session to park; sql> grant create table to park; sql> grant create view to park; ## 권한 취소 sql> revoke create vi session from park; revoke select on emp from test ##DB 모든 사용자에게 권한 주기 sql> grant create session to public; ## with admin option을 줘서 db관리자가 아님에도 불구 하고 다른사용자에게 권한 주기 sql> conn system/manager sql> grant create table to park whith admin option; ## 시스템 role grant connect, resource, dba, exp_full_database, imp_full_database, sysdba, sysoper to kopuk; ######### 9i부터..... SQL> grant select any dictionary to scott; Grant succeeded. ########## 부여된 롤 검색 SQL> select grantee, granted_role from dba_role_privs where grantee='MAY'; ########## 부여받은 롤 CONNECT, RESOURCE에 부여된 시스템 권한 확인하기.... SQL> select grantee,privilege from dba_sys_privs where grantee in ('CONNECT','RESOURCE'); ****************************************************** # 사용자가 접근 가능한 시스템 권한 보기... select * from user_sys_privs; select grantee,privilege from dba_sys_privs; # 사용자가 접근 가능한 테이블 권한 ... select * from user_tab_privs # 사용자가 접근 가능한 role 보기 select * from user_role_privs; # 부 여받은 object 열 권한보기 select * from user_col_privs_recd; # 롤에 부여된 시스템 권한 select * from role_sys_privs; # 롤에 부여된 테이블 권한에 select * from role_tab_privs; # 부여해준 object 권한보기.... select * from user_tab_privs_made; # 부여받은 object 권한보기..... select * from user_tab_privs_recd; # 부여해준 object 열 권한보기 select * from user_col_privs_made; |
Comment | |||
---|---|---|---|
등록된 코멘트가 없습니다. |