

 Amazon Redshift는 패치 198부터 새 Python UDF 생성을 더 이상 지원하지 않습니다. 기존 Python UDF는 2026년 6월 30일까지 계속 작동합니다. 자세한 내용은 [블로그 게시물](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)을 참조하세요.

# 사용자별로 여러 정책 결합
<a name="t_rls_combine_policies"></a>

Amazon Redshift에서 RLS는 사용자 및 객체별로 여러 정책을 연결하는 기능을 지원합니다. 한 사용자에 대해 여러 정책이 정의되어 있는 경우, Amazon Redshift는 테이블에 대한 RLS CONJUNCTION TYPE 설정에 따라 AND 또는 OR 구문을 사용하여 모든 정책을 적용합니다. 접속사 유형에 대한 자세한 정보는 [ALTER TABLE](r_ALTER_TABLE.md) 섹션을 참고하세요.

테이블에 대한 여러 정책이 사용자에게 연결될 수 있습니다. 사용자에게 여러 정책이 직접 연결되어 있거나 사용자가 여러 역할에 속해 있으며, 역할별로 서로 다른 정책이 연결되어 있습니다.

주어진 관계에서 여러 정책이 행 액세스를 제한해야 하는 경우 관계의 RLS CONJUNCTION TYPE을 AND로 설정할 수 있습니다. 다음 예제를 살펴보세요. Alice는 지정된 정책으로 'catname'이 NBA인 Sports 이벤트만 볼 수 있습니다.

```
-- Create an analyst role and grant it to a user named Alice.
CREATE ROLE analyst;
CREATE USER alice WITH PASSWORD 'Name_is_alice_1';
GRANT ROLE analyst TO alice;

-- Create an RLS policy that only lets the user see sports.
CREATE RLS POLICY policy_sports
WITH (catgroup VARCHAR(10))
USING (catgroup = 'Sports');

-- Create an RLS policy that only lets the user see NBA.
CREATE RLS POLICY policy_nba
WITH (catname VARCHAR(10))
USING (catname = 'NBA');

-- Attach both to the analyst role.
ATTACH RLS POLICY policy_sports ON category TO ROLE analyst;
ATTACH RLS POLICY policy_nba ON category TO ROLE analyst;

-- Activate RLS on the category table with AND CONJUNCTION TYPE. 
ALTER TABLE category ROW LEVEL SECURITY ON CONJUNCTION TYPE AND;

-- Change session to Alice.
SET SESSION AUTHORIZATION alice;

-- Select all from the category table.
SELECT catgroup, catname
FROM category;

 catgroup | catname 
---------+---------
 Sports   | NBA
(1 row)
```

주어진 관계에서 여러 정책이 사용자가 더 많은 행을 보도록 허용해야 하는 경우 관계의 RLS CONJUNCTION TYPE을 OR로 설정할 수 있습니다. 다음 예제를 살펴보세요. Alice는 지정된 정책으로 'Concerts'와 'Sports'만 볼 수 있습니다.

```
-- Create an analyst role and grant it to a user named Alice.
CREATE ROLE analyst;
CREATE USER alice WITH PASSWORD 'Name_is_alice_1';
GRANT ROLE analyst TO alice;

-- Create an RLS policy that only lets the user see concerts.
CREATE RLS POLICY policy_concerts
WITH (catgroup VARCHAR(10))
USING (catgroup = 'Concerts');

-- Create an RLS policy that only lets the user see sports.
CREATE RLS POLICY policy_sports
WITH (catgroup VARCHAR(10))
USING (catgroup = 'Sports');

-- Attach both to the analyst role.
ATTACH RLS POLICY policy_concerts ON category TO ROLE analyst;
ATTACH RLS POLICY policy_sports ON category TO ROLE analyst;

-- Activate RLS on the category table with OR CONJUNCTION TYPE. 
ALTER TABLE category ROW LEVEL SECURITY ON CONJUNCTION TYPE OR;

-- Change session to Alice.
SET SESSION AUTHORIZATION alice;

-- Select all from the category table.
SELECT catgroup, count(*)
FROM category
GROUP BY catgroup ORDER BY catgroup;

 catgroup | count 
---------+-------
 Concerts |  3
 Sports   |  5
(2 rows)
```