At dbms_mview.refresh, ORA-28081 occurs

(Doc ID 2419313.1)

Last updated on JULY 09, 2018

Applies to:

Oracle Database - Enterprise Edition - Version 11.2.0.4 and later
Information in this document applies to any platform.

Goal

As described in the manual, "to the refresh of the materialized view"
granting of EXEMPT REDACTION POLICY.

Home/Database/Oracle/Oracle Database/Release 12.2
Advanced Security Guide
13 Security Considerations for Oracle Data Redaction
13.5 Oracle Data Redaction Policies on Materialized Views

However, ensure that the creator of the materialized view, or the user who performs the refresh of the materialized view, is not blocked by any Data Redaction policies.

=========================================================================
- testcase

conn / as sysdba

create user A identified by welcome1 ;
grant CREATE SESSION to A ;
grant UNLIMITED TABLESPACE to A ;
grant CREATE TABLE to A ;
grant create materialized view to A;
grant execute on dbms_mview to A;

create user B identified by welcome1 ;
grant CREATE SESSION to B;
grant RESOURCE to B;
grant UNLIMITED TABLESPACE to B;
grant CREATE DATABASE LINK to B;
grant ALTER DATABASE LINK to B;
grant EXEMPT REDACTION POLICY to B;
grant DROP ANY TABLE to B;
grant EXECUTE ON DBMS_ERRLOG to B;
grant ALTER ANY MATERIALIZED VIEW to B;
grant ANALYZE ANY to B;
grant ALTER SESSION to B;

conn A/welcome1
create table mytest( id varchar2(254) not null, name varchar2(254) );
grant select on A.mytest to B;

INSERT INTO A.mytest (ID, NAME)
select '1', 'one' from dual union
select '2', 'two' from dual union
select '3', 'three' from dual union

col id for a10
col name for a20
select id,name from A.mytest ;
create materialized view mytest_view as select id, name from mytest;

conn / as sysdba

begin DBMS_REDACT.ADD_POLICY (
object_schema => 'A',
object_name => 'mytest',
policy_name => 'mytest_policy',
expression => '1=1');
end;
/

begin DBMS_REDACT.ALTER_POLICY (
object_schema => 'A',
object_name => 'mytest',
policy_name => 'mytest_policy',
action => DBMS_REDACT.ADD_COLUMN,
column_name => 'name',
function_type => DBMS_REDACT.FULL);
end;
/

grant EXEMPT REDACTION POLICY to B;

conn b/welcome1
exec dbms_mview.refresh('A.MYTEST_VIEW', 'c', NULL,TRUE, FALSE, 1, 0, 0, FALSE, FALSE);

=========================================================================

Solution

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms