---
title: Creating a SQL Policy
slug: kronpam-reference-guide-3-9-0/creating-a-sql-policy
description: Learn how to prevent or allow the execution of queries using SQL policies. Follow the steps outlined in this document to navigate to the Session Policy section, open the Policy Key tab, and restrict or permit specific queries or regex. Choose the suitable
docTags: 
createdAt: 2022-08-01T16:22:50.000Z
---

The execution of queries can be prevented or allowed by SQL policies:

1. Navigate to **Policy  Control > Session Policy.**
2. Click the +**Add** button next to th&#x65;**&#x20;Policy Key Title.**
3. Select th&#x65;**&#x20;Policy Key Type&#x20;**&#x69;n the opened pop-up.
   - Select white or black key.
4. Enter the query (or regex) to prevent or allow.
5. Select the policy type and element type.
6. Click **Save.**

:::hint{type="info"}
At least one policy key must be assigned to the related realm for SQL proxies.
\*If only black key policies are defined in a realm, all remaining queries will be white key.
\*If only white key polices are defined in a realm, all remaining queries will be black key.
\*If only the “.” regex is defined as white key, all queries are allowed to run.
\*If only the “.” regex is defined as a black key, all queries will be blocked.
:::

![](https://api.archbee.com/api/optimize/g9cApVza9NIhSh0pjZYtA/7ZMcotShytrT1liLKJpeT_image.png "SQL Policy Key Definition / Key Type selection is White Key")

The conditions listed in the table below are restricted by default to prevent the inference of masked data. If required, these conditions should be defined as white keys and assigned to the relevant policy groups.



| Type      | Condition / Function Name |
| --------- | ------------------------- |
| Condition | C$WHERE$                  |
| Condition | C$WHEN$                   |
| Condition | C$THEN$                   |
| Condition | C$ORDER BY$               |
| Condition | C$GROUP BY$               |
| Condition | C$PARTITION$              |
| Condition | C$EXISTS$                 |
| Condition | C$IS NULL$                |
| Condition | C$IN$                     |
| Condition | C$ON$                     |
| Condition | C$BETWEEN$                |
| Condition | C$FOR$                    |
| Condition | C$ELSE$                   |
| Condition | C$NOT$                    |
| Condition | C$CASE$                   |
| Function  | C$SWITCH$                 |
| Function  | C$CAST$                   |
| Function  | C$EXTRACT$                |
| Function  | C$PARENTHESIS$            |
| Function  | C$INSERT$                 |
| Function  | C$UPDATE$                 |
| Function  | C$PIVOT$                  |
| Function  | C$TIMEZONE$               |
| Function  | C$EQUALSTO$               |

