Overview
The DBA_RLS_POLICIES view is a tenant-level view that displays the row-level security (RLS) policy information defined on all tables in the current user's tenant, including the policy name, associated table, policy type, applicable command types, bound role, and USING/WITH CHECK expressions.
The description is as follows:
- This view only displays policies created directly on a table using the
CREATE POLICYstatement. - This view does not filter rows by policy owner. Regular users must first obtain the
SELECTprivilege on this view to query it; after authorization, they can view policy expressions from other databases.
Columns
Column |
Type |
Nullable |
Description |
|---|---|---|---|
| POLICY_NAME | char(128) | NO | Policy name. |
| TABLE_SCHEMA | char(128) | NO | The name of the database to which the policy-associated table belongs. |
| TABLE_NAME | char(128) | NO | The table name associated with the policy. |
| POLICY_TYPE | char(16) | NO | Policy type: PERMISSIVE or RESTRICTIVE. |
| COMMAND_TYPE | char(64) | NO | DML operations supported by the policy: ALL, SELECT, INSERT, UPDATE, DELETE, or a combination thereof (separated by commas). |
| ROLES | char(4096) | YES | List of roles or usernames bound to the policy (separated by commas). PUBLIC Indicates that the permission takes effect for all users. It may be when the referenced role has been deleted. NULL, which is not equal to PUBLIC. |
| USING_EXPRESSION | char(65535) | YES | The policy's USING Row filter expression text; if not configured, it is NULL. |
| WITH_CHECK_EXPRESSION | char(65535) | YES | The policy's WITH CHECK The text of the write operation validation expression. If not configured, it is NULL. |
The description is as follows:
WITH_CHECK_EXPRESSION IS NULLdoes not necessarily indicate that no write check is performed. ForALLorUPDATEstrategies that use onlyUSING, theUSINGclause is implicitly treated as a write check during execution.- For the table-level RLS switch, check the
ROW_SECURITYandROW_SECURITY_FORCEDfields in theinformation_schema.TABLESview. The existence of a policy does not affect these two fields.
Sample query
Query the strategy on the hr.employees table:
SELECT * FROM oceanbase.DBA_RLS_POLICIES WHERE TABLE_SCHEMA = 'hr' AND TABLE_NAME = 'employees';
The sample result is as follows:
+------------------+--------------+------------+-------------+---------------+----------+------------------------------------------+------------------------------------------+
| POLICY_NAME | TABLE_SCHEMA | TABLE_NAME | POLICY_TYPE | COMMAND_TYPE | ROLES | USING_EXPRESSION | WITH_CHECK_EXPRESSION |
+------------------+--------------+------------+-------------+---------------+----------+------------------------------------------+------------------------------------------+
| emp_dept_policy | hr | employees | PERMISSIVE | SELECT | PUBLIC | dept_id = current_setting('app.dept_id') | NULL |
| mgr_write_policy | hr | employees | RESTRICTIVE | INSERT,UPDATE | manager | dept_id = current_setting('app.dept_id') | dept_id = current_setting('app.dept_id') |
| hr_admin_policy | hr | employees | PERMISSIVE | ALL | hr_admin | 1=1 | NULL |
+------------------+--------------+------------+-------------+---------------+----------+------------------------------------------+------------------------------------------+