GRANT SELECT --,INSERT, ... etc ...
ON 해당테이블
TO 해당유저
WITH GRANT OPTION --종속철회
* 이렇게 권한을 주시던가 아니면 해당 유저에게 권한을 죄다 이행해 주는 프로시져를 사용하시면 편할듯 싶습니다.
프로시져.
--procedure source
CREATE OR REPLACE PROCEDURE grant_on_table (privs IN VARCHAR2, user_name IN VARCHAR2)
AS
cursor1 INTEGER;
cursor2 INTEGER;
t_name VARCHAR2(30);
rows_proces1 INTEGER;
rows_processed INTEGER;
BEGIN
cursor1 := DBMS_SQL.OPEN_CURSOR;
cursor2 := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE (cursor1, 'select table_name from user_tables', dbms_sql.v7);
DBMS_SQL.DEFINE_COLUMN (cursor1, 1, t_name, 30);
rows_processed := DBMS_SQL.EXECUTE (cursor1);
LOOP
if DBMS_SQL.FETCH_ROWS (cursor1) > 0 then
DBMS_SQL.COLUMN_VALUE (cursor1, 1, t_name);
DBMS_SQL.PARSE(cursor2,'grant '|| privs ||' on '|| t_name || ' to ' || user_name,dbms_sql.native);
rows_proces1 := DBMS_SQL.EXECUTE(cursor2);
else
exit;
end if;
END LOOP;
DBMS_SQL.CLOSE_CURSOR (cursor2);
DBMS_SQL.CLOSE_CURSOR (cursor1);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(sqlerrm);
if DBMS_SQL.IS_OPEN (cursor1) then
DBMS_SQL.CLOSE_CURSOR (cursor1);
end if;
END;
--procedure 실행
SQL>EXEC grant_on_table('all', 'new_user'); --로그온한 유저의 모든 권한이 새로운 유저인 new_user로 복사