We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9
Implementing Row-Level
Security (RLS) in Oracle
This document outlines the steps to implement Row-Level Security (RLS) in Oracle for the user PRACTICE1. It includes creating a new user, setting up an EMP table with sample data, defining the necessary context, procedure, and function, and applying the RLS policy. Testing steps are also included to validate the implementation.
Step 1: Create the User
Create the user PRACTICE1 and grant the required privileges.
CREATE USER PRACTICE1 IDENTIFIED BY practice1;
GRANT CONNECT, RESOURCE TO PRACTICE1;
ALTER USER PRACTICE1 QUOTA UNLIMITED ON USERS;
GRANT CREATE SESSION, CREATE TABLE, CREATE PROCEDURE,
create or replace function dept_predicate(schema_name in varchar2,
object_name in varchar2) return varchar2 is lv_predicate varchar2(1000); begin lv_predicate := 'username = sys_context(''test'', ''username'')'; return lv_predicate; exception when others then raise_application_error(-20001, 'Error in dept_predicate: ' || sqlerrm); end; /
Step 7: Apply the RLS Policy
Attach the RLS policy to the EMP table.
BEGIN DBMS_RLS.ADD_POLICY( object_schema => 'PRACTICE1',