> ## Documentation Index
> Fetch the complete documentation index at: https://villagesql.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# MySQL용 vsql_currency 확장 기능

> vsql_currency 확장 기능은 164개의 ISO 4217 코드 중 하나를 1바이트에 담고 입력 시 대소문자를 구분하지 않는 currency 열 유형을 MySQL에 추가합니다.

통화 코드 열은 보통 `CHAR(3)`이며, 통화가 아닌 것까지 포함해 아무 세 글자나
받습니다. `vsql_currency`는 pg-currency가 지원하는 164개의 ISO 4217 코드를
1바이트에 담고, 대소문자 구분 없이 받아들이며, 정규 대문자 형식으로 출력하는
`currency` 유형을 추가합니다.

| | |
| - | - |
| **관리자** | VillageSQL |
| **소스 및 전체 문서** | [villagesql/vsql-currency](https://github.com/villagesql/vsql-currency) |
| **라이선스** | GPL-2.0 |
| **작성 언어** | Rust |

## 설치

`vsql_currency`는 서버와 함께 번들로 제공되지 않으므로, 먼저 저장소에서 빌드한
다음 생성된 `vsql_currency.veb`를 `veb_dir` 시스템 변수가 가리키는 디렉터리에
복사하세요. 그런 다음 설치합니다:

```sql theme={null}
INSTALL EXTENSION vsql_currency;
```

설치되었는지 확인합니다:

```sql theme={null}
SELECT EXTENSION_NAME
FROM INFORMATION_SCHEMA.EXTENSIONS
WHERE EXTENSION_NAME = 'vsql_currency';
```

```
+----------------+
| EXTENSION_NAME |
+----------------+
| vsql_currency  |
+----------------+
```

빌드 지침은 [저장소](https://github.com/villagesql/vsql-currency)에 있습니다.

## 추가되는 기능

### currency 유형

```sql theme={null}
CREATE TABLE prices (
    sku    VARCHAR(8) PRIMARY KEY,
    amount DECIMAL(10,2),
    unit   currency
);
```

### 함수

| 함수 | 반환값 | 설명 |
| - | - | - |
| `currency_count()` | int | 확장 기능이 아는 코드의 개수 |
| `is_currency(code)` | int | 문자열이 유효한 ISO 4217 코드이면 1, 아니면 0 |
| `supported_currencies(prefix)` | text | 접두사로 좁힌 코드 목록을 JSON 배열로 반환 |

## 예제

코드를 아무 대소문자로 쓰고, 정규 형식으로 정렬된 상태로 다시 읽습니다:

```sql theme={null}
INSERT INTO prices VALUES
    ('A-100', 19.99, 'usd'),
    ('A-101', 24.50, 'EUR'),
    ('A-102', 3100,  'jpy');

SELECT sku, amount, unit FROM prices ORDER BY unit;
```

```
+-------+---------+------+
| sku   | amount  | unit |
+-------+---------+------+
| A-101 |   24.50 | EUR  |
| A-102 | 3100.00 | JPY  |
| A-100 |   19.99 | USD  |
+-------+---------+------+
```

코드를 신뢰하기 전에 확인하고, 관심 있는 코드를 나열합니다:

```sql theme={null}
SELECT currency_count() AS codes, is_currency('XYZ') AS xyz, is_currency('GBP') AS gbp;
```

```
+-------+------+------+
| codes | xyz  | gbp  |
+-------+------+------+
|   164 |    0 |    1 |
+-------+------+------+
```

```sql theme={null}
SELECT supported_currencies('C') AS starting_with_c;
```

```
+---------------------------------------------------------------------+
| starting_with_c                                                     |
+---------------------------------------------------------------------+
| ["CAD","CDF","CHF","CLP","CNY","COP","CRC","CUC","CUP","CVE","CZK"] |
+---------------------------------------------------------------------+
```

## 참고 항목

* [데이터 유형 선택하기](https://villagesql.com/docs/en/guides/choosing-data-types.md) — 더 좁은 유형이 가치 있는 경우
* [확장 기능 설치](https://villagesql.com/docs/ko/extensions/install.md) — `INSTALL EXTENSION`의 동작 방식과 서버가 번들을 찾는 위치
* [사용 가능한 확장 기능](https://villagesql.com/docs/ko/extensions/catalog) — 전체 카탈로그
* [villagesql/vsql-currency](https://github.com/villagesql/vsql-currency) — 소스, 빌드 지침, 알려진 제한 사항


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.