ORACLE/Admin

10장 User 관리하기

히드라야 2015. 4. 6. 11:34

◎ Schema & User

 □ user가 만들어 놓은 Object의 집합 = Schema

※ table, index, view, constraint, triger , dblink, 등이 전부 Object ? 

User 생성 & 조회하기 

   

  ※ 보통 새로운 업무가 생성될때 user생성 → 관리적 측면


  □ 생성 순서 

① default tablespace를 결정 tablespace 생성 

② temporary tablespace 생성 

③ 사용자 생성

④ 프로파일, 권한, Role등 생성 후 할당 

[조회하기]

set line 200

col tabpespace_name for a10

col file_name for a50

select tablespace_name, bytes/1024/1024 MB, file_name

from dba_data_files;



[table space 만들기]

create tablespace ts_webhard

datafile '/app/oracle/oradata/testdb/ts_web01.dbf' size 100M;



[index용 table space 만들기]

create tablespace ts_web_idx

datafile '/app/oracle/oradata/testdb/ts_idx01.dbf' size 10M


[temporary table space 만들기]

create tablespace ts_web_idx

datafile '/app/oracle/oradata/testdb/ts_idx01.dbf' size 10M


[temporary table space 조회하기]

col tablespace_name for a10

col file_name for a50

select file_id, tablespace_name, bytes/1024/1024 MB, file_name from dba_temp_files ;


[User 생성하기]

create user webuser

identified by 12345

default tablespace ts_webhard

temporary tablespace temp_web

quota unlimited on ts_webhard

quota 0m on system;



[권한 주기]

grant resource, connect to webuser;


[바꾸기]

alter user webuser

identified by hms1988;


[할당된 user당 tablespace 조회하기 ]

set line 200

col default_tablespace for a10

col temporary_tablespace for a10

select username, default_tablespace "Default TS", 

temporary_tablespace "Temp TS"

from dba_users

where username='WEBUSER';



 

  □ 조회 하기  


◎ profile 관리

종류 

 ① password profile

Failed_login_attempts : 사용자가 몇회 비번을 틀렸을때 계정을 Lock 할건지

Password_lock_time: Lock의 경우 기간설정 (일단위)  

Password_life_time: 동일한 암호를 몇일간 사용하게 할것인지(일단위)

Password_grace_time: Password_life_time 기간이 종료되었을 때 몇일

 간이나 변경할 기간을 허용할 것인가(일단위) (pw 나중에 바꾸기 기능)

Password_reuse_time: 동일한 암호를 다시사용 못하게 설정하는 기간

Password_reuse_max: 재사용 하는경우 최대 사용 횟수

Password_verify_function: 함수를 통해 암호 검증 

 ② resource profile

CPU_PER_SESSION:CPU를 점유하는 시간 (1/100 단위)

SESSION_PER_USER: 1개의 개정의 동시 접속자 수 설정

CONNECT_TIME: 하루동안 접속할 수 있는 총 시간 (분단위)

IDLE_TIME: 연속적인 휴먼시간이 넘으면 접속해제(은행 15분)

  ★위험할 수 있으니 조심해야함, 오래걸리는 SQL문장 

LOCAL_READS_PER_SESSION: 한SESSION에서의 최대 BOLCK수 

PRIVATE_SGA:

CPU_PER_CALL:

LOGICAL_READS_PER_CALL:

□ profie 실습 (할당 하기)


[사용자가 받고있는 PROFILE 조회]

set pages 50 

select username , profile

from dba_users

where username='WEBUSER';


[profile 설정 조회 하기]

set line 200

col profile for a13

col resource_name for a30

col resource for a10

col limit for a10

select * from dba_profiles

where profile='TEST_PROF';


[profile을 user에게 할당해주기]

alter user webuser profile test_prof;

alter user webuser profile test_reprof;


※가장 최근에 입력한 profile만 적용됨


[사용안하는 profile 삭제]

drop profile test_prof;


※ 사용중일 경우 ORA-02382 오류가 남 


[사용하는 profile 삭제]

drop profile test_prof cascade;


※ 사용중인것을 삭제하면 default로 변경됨 

※ JAVA로 만들어져서 전부 객체지향으로 가는듯?



 

◎ privilege(권한) 관리 


※ 자신의 소유의 계정에는 상관이 없는 듯함...

   만일 다른 user의 계정의 데이터를 이용할때 사용 



□ 종류

① SYSTEM 권한

② SYSOPER / SYSDBA 권한

□ 권한 할당, 해제 , 조회 실습  

[system 관련 권한 할당]

grant create table, create session to scott;


[system 관련 권한 뺏기 ]

revoke create table from scott;


[특정 사용자 권한 조회하기]

select * from dba_sys_privs

where grantee='WEBUSER'


[Object 관련 권한 할당]

grant select on webuser.abc to scott;


grant select on webuser.abc to scott with grant option;

(내가 가진권한을 다른 user에게 줄 수 있음 )

[Object 관련 권한 뺏기]

revoke select on webuser.abc from scott;


※ WHERE절 대문자로 쓰기 




◎ Role 관리

□ privilige의 모아서 한번에 user에게 할당하기 

□ Role 생성, 할당 확인 등 

[Role 만들기 ]

create role trole;


[ROLE에 권한 넣어주기]

grant create session, create table to trole;


[ROLE 할당하기]

grant trole to scott;


[사용자별 Role 조회]

select * from dba_role_privs where grantee='WEBUSER';


[Role 안에 어떤 privilige 조회]

select * from dba_sys_privs where grantee='CONNECT';