

 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="r_Boolean_type"></a>

부울 데이터 형식은 단일 바이트 열에 true 또는 false 값을 저장하는 데 사용됩니다. 다음 표는 부울 값에서 가능한 세 가지 상태와 이러한 상태를 나타내는 리터럴 값에 대해 설명한 것입니다. 입력 문자열에 상관없이 Boolean 열은 true일 때는 "t"를, 그리고 false일 때는 "f"를 저장 및 출력합니다.

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/redshift/latest/dg/r_Boolean_type.html)

IS 비교를 사용해 WHERE 절의 조건자로 부울 값만 확인할 수 있습니다. IS 비교는 SELECT 목록의 부울 값에는 사용할 수 없습니다.

## 예제
<a name="r_Boolean_type-examples"></a>

BOOLEAN 열을 사용하여 각 고객의 "Active/Inactive" 상태를 CUSTOMER 테이블에 저장할 수 있습니다.

```
create table customer(
custid int,
active_flag boolean default true);
```

```
insert into customer values(100, default);
```

```
select * from customer;
custid | active_flag
-------+--------------
   100 | t
```

CREATE TABLE 문에서 기본값(`true` 또는 `false`)을 지정하지 않은 경우에는 기본값을 삽입하더라도 NULL 값을 삽입하는 것과 똑같습니다.

다음은 USERS 테이블에서 스포츠는 좋아하지만 영화를 좋아하지 않는 사용자를 선택하는 쿼리 예입니다.

```
select firstname, lastname, likesports, liketheatre
from users
where likesports is true and liketheatre is false
order by userid limit 10;

firstname |  lastname  | likesports | liketheatre
----------+------------+------------+-------------
Lars      | Ratliff    | t          | f
Mufutau   | Watkins    | t          | f
Scarlett  | Mayer      | t          | f
Shafira   | Glenn      | t          | f
Winifred  | Cherry     | t          | f
Chase     | Lamb       | t          | f
Liberty   | Ellison    | t          | f
Aladdin   | Haney      | t          | f
Tashya    | Michael    | t          | f
Lucian    | Montgomery | t          | f
(10 rows)
```

다음은 USERS 테이블에서 록 음악을 좋아하는지 알 수 없는 사용자를 선택하는 예입니다.

```
select firstname, lastname, likerock
from users
where likerock is unknown
order by userid limit 10;

firstname | lastname | likerock
----------+----------+----------
Rafael    | Taylor   |
Vladimir  | Humphrey |
Barry     | Roy      |
Tamekah   | Juarez   |
Mufutau   | Watkins  |
Naida     | Calderon |
Anika     | Huff     |
Bruce     | Beck     |
Mallory   | Farrell  |
Scarlett  | Mayer    |
(10 rows)
```

다음 예에서는 SELECT 목록에 IS 비교를 사용했기 때문에 오류를 반환합니다.

```
select firstname, lastname, likerock is true as "check"
from users
order by userid limit 10;

[Amazon](500310) Invalid operation: Not implemented
```

다음 예는 SELECT 목록에서 IS 비교 대신에 같음 비교( = )를 사용했기 때문에 성공합니다.

```
select firstname, lastname, likerock = true as "check"
from users
order by userid limit 10;

firstname | lastname  | check
----------+-----------+------
Rafael    | Taylor    |      
Vladimir  | Humphrey  |      
Lars      | Ratliff   | true 
Barry     | Roy       |      
Reagan    | Hodge     | true 
Victor    | Hernandez | true 
Tamekah   | Juarez    |      
Colton    | Roy       | false
Mufutau   | Watkins   |      
Naida     | Calderon  |
```