grant flashback on scott.emp to jim;or you can grant user jim a system privilege to flashback any table:
grant flashback any table to jim;
Minimalistic Oracle contains a collection of practical examples from my encounters with Oracle technologies. When relevant, I also write about other technologies, like Linux or PostgreSQL. Many of the posts starts with "how to" since they derive directly from my own personal experience. My goal is to provide simple examples, so that they can be easily adapted to other situations.
grant flashback on scott.emp to jim;or you can grant user jim a system privilege to flashback any table:
grant flashback any table to jim;
ALTER TABLE JIM.TRANSACTION ADD ( CONSTRAINT TRANSACTION_FK FOREIGN KEY (TRANS_ID) REFERENCES DWIGHT.TRANSACTION_HISTORY(TRANS_ID) );
GRANT REFERENCES ON DWIGHT.TRANSACTION_HISTORY TO JIM;
create role my_ro_role;
grant create job to scott;
ORA-30510: system triggers cannot be defined on the schema of SYS user
conn system/password create or replace trigger scott.add_to_ro_role after CREATE on schema declare l_str varchar2(255); l_job number; begin if ( ora_dict_obj_type = 'TABLE' ) then l_str := 'execute immediate "grant select on ' || ora_dict_obj_name || ' to my_ro_role";'; dbms_job.submit( l_job, replace(l_str,'"','''') ); end if; end; /
The SELECT ANY DICTIONARY privilege no longer permits access to security sensitive data dictionary tables DEFAULT_PWD$, ENC$, LINK$, USER$, USER_HISTORY$, and XS$VERIFIERS. This change increases the default security of the database by not allowing access to a subset of data dictionary tables through the SELECT ANY DICTIONARY privilege. |
set serveroutput on DECLARE CURSOR c1 IS select username from dba_users where username like 'IT%' or username like 'MAITD%'; BEGIN FOR x IN c1 LOOP dbms_output.put_line('user ' || x.username || ' processed.' ); execute immediate('GRANT SELECT ON SYS.IND$ TO ' || x.username); execute immediate('GRANT SELECT ON SYS.OBJ$ TO ' || x.username); execute immediate('GRANT SELECT ON SYS.TAB$ TO ' || x.username); execute immediate('GRANT SELECT ON SYS.USER$ TO ' || x.username); execute immediate('GRANT SELECT ON SYS.V_$DATABASE TO ' || x.username); execute immediate('GRANT SELECT ON SYS.V_$INSTANCE TO ' || x.username); execute immediate('GRANT SELECT ON SYS.V_$LATCH TO ' || x.username); execute immediate('GRANT SELECT ON SYS.V_$LIBRARYCACHE TO ' || x.username); execute immediate('GRANT SELECT ON SYS.V_$MYSTAT TO ' || x.username); execute immediate('GRANT SELECT ON SYS.V_$PROCESS TO ' || x.username); execute immediate('GRANT SELECT ON SYS.V_$ROWCACHE TO ' || x.username); execute immediate('GRANT SELECT ON SYS.V_$SESSION TO ' || x.username); execute immediate('GRANT SELECT ON SYS.V_$SESSTAT TO ' || x.username); execute immediate('GRANT SELECT ON SYS.V_$SESS_IO TO ' || x.username); execute immediate('GRANT SELECT ON SYS.V_$SGASTAT TO ' || x.username); execute immediate('GRANT SELECT ON SYS.V_$STATNAME TO ' || x.username); execute immediate('GRANT SELECT ON SYS.V_$SYSSTAT TO ' || x.username); execute immediate('GRANT SELECT ON SYS.V_$SYSTEM_EVENT TO ' || x.username); END LOOP; END; /
SELECT NAME , DETECTED_USAGES , FIRST_USAGE_DATE , LAST_USAGE_DATE, LAST_SAMPLE_DATE, CURRENTLY_USED, DESCRIPTION FROM DBA_FEATURE_USAGE_STATISTICS WHERE FIRST_USAGE_DATE IS NOT NULL AND NAME LIKE 'Privilege%';
NAME | DETECTED_USAGES | FIRST_USAGE_DATE | LAST_USAGE_DATE | LAST_SAMPLE_DATE | CURRENTLY_USED | DESCRIPTION |
---|---|---|---|---|---|---|
Privilege Capture | 11 |
27.05.2017 03:41:35 | 05.08.2017 03:46:46 | 05.08.2017 03:46:46 | TRUE | Privilege Capture is being used |
BEGIN DBMS_PRIVILEGE_CAPTURE.create_capture( name => 'my_policy', type => DBMS_PRIVILEGE_CAPTURE.g_context, condition => 'SYS_CONTEXT(''USERENV'', ''SESSION_USER'') = ''SCOTT''' ); END; /
COLUMN name FORMAT A15 COLUMN roles FORMAT A20 COLUMN context FORMAT A30 SET LINESIZE 100 SELECT name, type, enabled, roles, context FROM dba_priv_captures ORDER BY name;
BEGIN DBMS_PRIVILEGE_CAPTURE.enable_capture('my_policy'); END; /
BEGIN DBMS_PRIVILEGE_CAPTURE.disable_capture( name => 'saga2_felles_policy' ); DBMS_PRIVILEGE_CAPTURE.generate_result( name => 'saga2_felles_policy' ); END; /
SET LINESIZE 200 COLUMN username FORMAT A20 COLUMN username FORMAT A20 COLUMN used_role FORMAT A30 COLUMN path FORMAT A50 COLUMN sys_priv FORMAT A30 COLUMN obj_priv FORMAT A8 COLUMN object_owner FORMAT A15 COLUMN object_name FORMAT A30 COLUMN object_type FORMAT A11 prompt ================================ prompt Which privileges have been used? prompt Look in DBA_USED_SYSPRIVS prompt ================================ SELECT username, sys_priv FROM dba_used_sysprivs WHERE capture = 'my_policy' ORDER BY username, sys_priv; prompt ================================ prompt How were the privileges granted prompt to the user? prompt Look in DBA_USED_SYSPRIVS_PATH prompt ================================ SELECT username, sys_priv, used_role, path FROM dba_used_sysprivs_path WHERE capture='my_policy' order by username,sys_priv; prompt ================================ prompt What object privileges were necessary? prompt Look in DBA_USED_OBJPRIVS prompt ================================ SELECT username, obj_priv, object_owner, object_name, object_type FROM dba_used_objprivs WHERE capture = 'my_policy'; prompt ================================ prompt How were the object privileges granted to the user? prompt Look in DBA_USED_OBJPRIVS_PATH prompt ================================ SELECT username, obj_priv, object_owner, object_name, used_role, path FROM dba_used_objprivs_path WHERE capture = 'my_policy'; exit
BEGIN DBMS_PRIVILEGE_CAPTURE.drop_capture( name => 'my_policy' ); END; /
select * from user_tab_privs_made;
GRANTEE | TABLE_NAME | GRANTOR | PRIVILEGE | GRANTABLE | HIERARCHY | COMMON | TYPE |
---|---|---|---|---|---|---|---|
PUBLIC | MYUSER | MYUSER | INHERIT PRIVILEGES | NO | NO | NO | USER |
connect scott/tiger CREATE VIEW MYVIEW AS SELECT FROM MYTABLE MT, V$DATABASE DB WHERE.... AND... ;
GRANT SELECT ON V_$DATABASE TO SCOTT;
GRANT SELECT ON OBM.sequence1 to SCOTT; GRANT DEBUG ON OBM.proceure1 to SCOTT;
SELECT 'GRANT DEBUG ON ' || OWNER || '.' || OBJECT_NAME || ' TO SCOTT;' FROM DBA_PROCEDURES WHERE OWNER = 'OBM' AND OBJECT_TYPE='PROCEDURE'; SELECT 'GRANT SELECT ON ' || SEQUENCE_OWNER || '.' || SEQUENCE_NAME || ' TO SCOTT;' FROM DBA_SEQUENCES WHERE SEQUENCE_OWNER = 'OBM';
GRANT SELECT ANY SEQUENCE TO SCOTT; GRANT DEBUG ANY PROCEDURE TO SCOTT;