본문 바로가기
Developer/DB

오라클 사용자 관리 및 권한 부여(회수)

by 순수한소년 2015. 1. 15.
728x90
반응형

 http://blog.naver.com/sunnsea/150108847959

 

User 생성

순서

1. 신규 사용자 deafault tablespace 생성

    SQL>create tablespace 테이블스페이스명 datafile '경로/파일명' size 00M;

2. 신규 사용자 temporary tablesapce 생성

    SQL>create temporary tablespace 임시테이블스페이스명 tempfile '경로/파일명' size 00M;

3. 신규 사용자 생성

    SQL>create user 유저명 identified by 패스워드

            default tablespace 테이블스페이스명

            temporary tablespace 임시테이블스페이스명

            quota unlimited on 테이블스페이스명  // 테이블스페이스에 할당량을 무제한으로 지정

            quota 0M on system;  //시스템 테이블스페이스는 못 사용하도록...옵션 사항

4. 적절한 프로파일, 권한, 롤 적용

    SQL>grant resource, connect   to  사용자명;   //적절한 권한을 부여한다.

 

사용자 default tablespace와 temporary tablesapce 확인

SQL>select username, default_tablespace, temporary_tablespace 

        from  dba_users  

        where  username = '유저명';

 

Profile

- 사용자 계정에 대한 제약사항 등 옵션을 미리 정의하는 기능

1. 패스워드 관련 파라미터

   1) Failed_login_attempts : 설정된 횟수만큼 로그인 연속 실패시 계정 잠금

   2) Password_lock_time : 계정이 잠기면 몇일을 잠글 것인지...DBA가 unlock 가능

   3) Password_life_time : 암호변경없이 기존 암호로 로그인할 수 있는 일수

   4) Password_grace_time : 동일암호 사용기간 만료시 암호변경을 위한 유예기간(일수)

   5) Password_reuse_time : 암호변경시 이전 암호를 재사용 할 수 없도록 설정하는 기간(일수)

   6) Password_reuse_max : 동일암호를 재사용시 최대 허용 횟수

   7) Password_verify_function : 암호의 안정성을 확인할 것인지 여부,

          오라클에서 제공하는 verify_function의 제약사항은

            (1) 최소 4글자 이상  (2) 사용자 ID와 다를 것  (3) 하나의 특수문자,알파벳,숫자 포함

            (4)이전 암호와 3글자 이상 다를것

 

2. Resource 관련 파라미터

   1) Cpu_per_session : 한 세션이 CPU를 연속적으로 사용할 수 있는 최대 시간,

                                  무한루프 방지 목적, 1/100 초 단위

   2) Session_per_user : 하나의 사용자 계정에 동시에 접속 가능한 사용자 수

   3) Connect_time : 하루동안 DB Server에 접속 가능한 총 시간

   4) Idle_time : 접속 후 어느 정도 사용하지 않으면 강제로 접속을 해제할 것인지, 분단위

   5) Logical_reads_per_session :  한 세션이 사용 가능한 최대 block 수

   6) Private_age : MTS / shared server 일 경우 해당 session의 SGA 사용량, byte 단위

   7) Cpu_per_call : 한 call당 cpu를 점유할 수 있는 시간, 1/100초 단위

   8) Logical_reads_per_call : 한 call당 읽을 수 있는 최대 block 수

 

3. Profile 생성, 적용, 삭제  

   1) 생성(예제) 및 확인

       SQL>create profile 프로파일명 limit   //생성

               failed_login_attempts 5

               password_lock_time  3

               password_life_time  20

               cpu_per_session   2000

               idle_time  30;

       SQL>select * from dba_profiles  where profile='프로파일명';  //생성 확인

 

    2) 적용 및 확인

       SQL>alter user  유저명  profile  프로파일명;  //사용자에게 프로파일 적용

       SQL>select  username, profile   //사용자에게 적용된 프로파일 확인

               from dba_users

               where  username='유저명';

 

    3) profile 삭제

       SQL>drop  profile  프로파일명  cascade; 

                  //cascade는 옵션, 현재 사용중인 profile 까지 삭제한다.

 

Privilege

- 오라클은 계정, 암호 생성후에도 적절한 권한을 부여해야만 접속도 하고 작업도 가능.

- Privilege는 크게 (1) system privilege 와 (2) object privilege 가 있다.

1. System Privilege

   1) session

       - create session : 서버 접속 권한

       - alter session : 접속상태에서 환경변수값 변경 권한

       - restricted session : Restricted mode로 open된 DB 접속 권한

   2) tablespace

       - create tablespace,  alter tablespace,  drop tablespace

            // tablespace 생성, 수정, 삭제 권한

       - unlimited tablespace : quota 옵션을 무시하고 tablespace의 무제한 사용 권한

   3) index

       - create any index,  drop any index,  alter any index

          //소유자와 무관하게 모든 테이블에 대한 인덱스 생성, 수정, 삭제 권한

   4) table

       - creat table  //자신 소유의 테이블 생성

       - create any table,  alter any table,  drop any table,

         update any table,  delete any table,  insert any table

          //소유자와 무관하게 모든 테이블에 대한 생성, 수정, 삭제 권한과

          //테이블에 저장된 data에 대한 수정, 삭제, 입력 권한

 

    ★ SYSOPER / SYSDBA privilege

        (1) SYSOPER

             - startup / shutdown

             - alter database mount / open

             - alter database backup control file to ...

             - recover database

             - alter database archivelog

             - restricted session

         (2) SYSDBA

             - SYSOPER privilege with admin option

             - create database

             - alter tablespace...begin backup / end backup

             - recover database until

 

2. Object Privilege

    - 테이블에 저장된 data에 대한 select, insert, update, delete 등을 할 수 있는 권한

 

3. 권한 부여 및 회수

   1) 권한 부여

      SQL>grant 권한명 to 유저명 [with admin option 또는 with grant option];

            //with admin option과 with grant option은 선택사항.

            //with admin option은 system privilege를 위임할 때 쓰이고,

            //with grant option은 object privilege를 위임할 때 쓴다.

            //DBA가 A에게 권한을 위임하고, 다시 A가 B에게 권한을 부여한 후

            //DBA가 A에게 위임한 권한을 회수할 경우

            //with admin option은 B의 권한이 해제되지 않지만

            //with grant option은 자동으로 B의 권한까지 회수 된다. 

      SQL>grant create table, create session to scott;

             //scott 유저에게 system privilege인 서버접속 및 테이블 생성 권한 부여

      SQL>grant 권한명 on 소유자.객체명 to 유저명 [with grant option];

            //object privilege 부여

      SQL>grant select on tiger.testtable to scott with grant option;  //예제

   2) 권한 회수

      SQL>revoke 권한명 from 유저명;

      SQL>revoke create table from scott;

      SQL>revoke select on tiger.testtable from scott;

 

Role

- 권한 그룹 : grant 명령으로 하나하나 권한을 부여하려면 시간과 노력이 많이 소요되므로

                   역할에 따른 권한을 미리 정의하고 한꺼번에 유저에게 할당하는 방식

- 사용방법  : (1)role 생성 -> (2) role에 적절한 권한 부여(회수) -> (3) 유저에게 role 할당(해제)

 

1. role 생성(삭제)

   SQL>create role 롤이름;

   SQL>drop role 롤이름 [cascade];

2. role에 권한 부여(회수)

   SQL>grant 권한명 to 롤이름;

   SQL>revoke 권한명 from 롤이름;

3. 유제에게 롤 할당(해제)

   SQL>grant  롤이름 to  유저명;  

   SQL>revoke 롤이름 from 유저명;

4. 유저에게 적용된 롤 확인

   SQL>select * from dba_role_privs where grantee='유저명';

5. Role에 부여된 권한 확인

   SQL>select * from dba_sys_privs where grantee='롤이름';

728x90
반응형