728x90
※복습
유저 생성 명령어
create user 유저명 identified by 패스워드
패스워드 변경 명령어
alter user 유저명 identified by 패스워드
system 권한 -> dba 관리자가 권한 관리
object 권한 -> object 소유자가 권한 관리
사용자 관리를 위한 데이터 사전
유저마다 권한이 다르기 때문에 할 수 있는 작업이 다름
user_users : 자신의 계정에 대한 정보
conn hr/hr
desc user_users;
select username, user_id, expiry_date, default_tablespace, created, account_status
from user_users;
expriry_date : 패스워드 변경 만기일(보통은 180일)
default_tablespace : 저장공간 위치
created : 언제 만들어졌는지
conn demo/demo
desc user_users;
select username, user_id, expiry_date, default_tablespace, created, account_status
from user_users;
demo 생성 시 tablespace를 정의하지 않았음. default_tablespace 생략 시 db에 정의된 default 값이 부여됨
user_sys_privs : 사용자에게 부여된 시스템 권한
desc user_sys_privs
select privilege, admin_option
from user_sys_privs;
privilege : 권한명
admin_option : admin_option 여부
user_tab_privs : 사용자에게 부여된 object 권한
desc user_tab_privs;
-- tab : table , view, sequence 를 뜻함
select owner, table_name, privilege, grantable
from user_tab_privs;


owner : Object 소유자
table_name : Object 이름(table만 뜻하는 것이 아님)
grantable : 권한 부여 옵션
user_col_privs : 사용자에게 부여된 column 레벨의 Object 권한에 대한 정보
conn hr/hr
-- HR -> DEMO에게 권한을 부여
grant update(job_id, email, department_id)
on employees
to demo;
conn demo/demo
update hr.employees
set email = 'abc@abc.com'
where employee_id = 200;


-- demo에 접속된 상태에서 확인
select * from user_tab_privs; -- 컬럼에 대한 권한은 알 수 없음
select * from user_col_privs; -- 컬럼에 대한 권한을 알 수 있음
select a.column_name, b.constraint_name, b.constraint_type, b.search_condition, b.r_constraint_name, c.table_name, c.column_name
from user_cons_columns a join user_constraints b
on (a.constraint_name = b.constraint_name)
join user_cons_colmns c
on (b.r_constraint_name = c.constraint_name)
where lower(a.table_name) = lower('&table_name');
728x90
'KDT > DB' 카테고리의 다른 글
240412 DB 순위 함수 (0) | 2024.04.12 |
---|---|
240402 DB - Top-N 분석 (0) | 2024.04.02 |
240327 DB - 데이터 제어어(DCL) (0) | 2024.03.27 |
240321 DB - 조건부 표현식 2 (0) | 2024.03.21 |
240320 DB - 객체 사용을 위한 Data Dictionary, 조건부 표현식 1 (0) | 2024.03.20 |