[ORACLE SQL 문법] 유저생성(CREATE,DROP), 권한부여(GRANT,REVOKE), 역할지정(ROLE) :: 소림사의 홍반장!
/* Multi Line Comments */
-- Single Line Comment

-- 유저생성
-- CREATE USER [USER_NAME]
-- IDENTIFIED BY [PASSWORD];

CREATE USER INHA
IDENTIFIED BY "1234";

--CONNECT
GRANT CREATE SESSION TO INHA;

--유저 삭제 
DROP USER INHA;

SELECT USERNAME, ACCOUNT_STATUS FROM DBA_USERS;

-- TEST1 USER 생성 
--  1. TEST1/1234
--  2. DEFAULT TABLESPACE ( 데이터들이 저장 될 테이블을 지정 ) 
--  3. LOCK/UNLOCK
  
--   ** ROLE **
--  CONNECT : CREATE SESSION
--  RESOURCE : 개발자들을 위한 롤
--  DBA : SYS바로 밑단계
  
--  4. GRANT CONNECT, RESOURCE

CREATE USER TEST1
IDENTIFIED BY "1234"
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP
ACCOUNT LOCK;

--GRANT
GRANT CONNECT, RESOURCE, DBA TO TEST1;
REVOKE DBA FROM TEST1;

--UNLOCK
ALTER USER TEST1
ACCOUNT UNLOCK;

--TEST1
SELECT * FROM USER_ROLE_PRIVS;
SELECT * FROM ROLE_SYS_PRIVS WHERE ROLE = 'RESOURCE';
SELECT * FROM ROLE_SYS_PRIVS WHERE ROLE = 'CONNECT';

다른 카테고리의 글 목록

Dev. 데이터베이스/SQL 예제 카테고리의 포스트를 톺아봅니다