# Policies

You can use policies to provide row-level security (RLS) in HEAVY.AI.

## CREATE POLICY

```sql
CREATE POLICY ON COLUMN table.column TO <name> VALUES ('string', 123, ...);
```

Create an RLS policy for a user or role (`<name>`); admin rights are required. All queries on the table for the user or role are automatically filtered to include only rows where the column contains any one of the values from the VALUES clause.

RLS filtering works similarly to a `WHERE column = value` clause, appended to every query or subquery on the table, would work. If policies on multiple columns in the same table are defined for a user or role, then a row is visible to that user or role if any one or more of the policies matches that row.

## DROP POLICY

```sql
DROP POLICY ON COLUMN table.column FROM <name>;
```

Drop an RLS policy for a user or role (`<name>`); admin rights are required. All values specified for the column by the policy are dropped. Effective values from another policy on an inherited role are not dropped.

## SHOW POLICIES

```sql
SHOW [EFFECTIVE] POLICIES <name>;
```

Displays a list of all RLS policies that exist for a user or role. If EFFECTIVE is used, the list also include any policies that exist for all roles that apply to the requested user or role.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.heavy.ai/sql/data-definition-ddl/policies.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
