

 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/)を参照してください。

# INITCAP 関数
<a name="r_INITCAP"></a>

指定された文字列内の各単語の先頭文字を大文字にします。INITCAP は、UTF-8 マルチバイト文字に対応しています (1 文字につき最大で 4 バイトまで)。

## 構文
<a name="r_INITCAP-synopsis"></a>

```
INITCAP(string)
```

## 引数
<a name="r_INITCAP-argument"></a>

 *string*   
`CHAR` 文字列、`VARCHAR` 文字列、あるいは `CHAR` または `VARCHAR` 型に暗黙的に評価される式。

## 戻り型
<a name="r_INITCAP-return-type"></a>

VARCHAR

## 使用に関する注意事項
<a name="r_INITCAP_usage_notes"></a>

INITCAP 関数は、文字列内の各単語の先頭文字を大文字にして、2 文字目以降を小文字 (のまま) にします。そのため、単語区切り文字として機能する文字 (スペース文字以外) を理解することが重要です。*単語区切り*文字は、任意の非英数字 (句読点、記号、および制御文字を含む) です。以下の文字はすべて、単語区切り文字です。

```
! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ 
```

タブ、改行文字、フォームフィード、ラインフィード、およびキャリッジリターンも単語区切り文字です。

## 例
<a name="r_INITCAP-examples"></a>

次の例では、TICKIT サンプルデータベースの CATEGORY テーブルと USERS テーブルからのデータを使用します。詳細については、「[サンプルデータベース](c_sampledb.md)」を参照してください。

CATDESC 列内の各単語の先頭文字を大文字にするには、次の例を使用します。

```
SELECT catid, catdesc, INITCAP(catdesc)
FROM category
ORDER BY 1, 2, 3;

+-------+--------------------------------------------+--------------------------------------------+
| catid |                  catdesc                   |                  initcap                   |
+-------+--------------------------------------------+--------------------------------------------+
|     1 | Major League Baseball                      | Major League Baseball                      |
|     2 | National Hockey League                     | National Hockey League                     |
|     3 | National Football League                   | National Football League                   |
|     4 | National Basketball Association            | National Basketball Association            |
|     5 | Major League Soccer                        | Major League Soccer                        |
|     6 | Musical theatre                            | Musical Theatre                            |
|     7 | All non-musical theatre                    | All Non-Musical Theatre                    |
|     8 | All opera and light opera                  | All Opera And Light Opera                  |
|     9 | All rock and pop music concerts            | All Rock And Pop Music Concerts            |
|    10 | All jazz singers and bands                 | All Jazz Singers And Bands                 |
|    11 | All symphony, concerto, and choir concerts | All Symphony, Concerto, And Choir Concerts |
+-------+--------------------------------------------+--------------------------------------------+
```

INITCAP 関数が先頭文字以外の大文字を大文字として保存しないことを示すには、次の例を使用します。例えば、文字列 `MLB` は `Mlb` になります。

```
SELECT INITCAP(catname)
FROM category
ORDER BY catname;

+-----------+
|  initcap  |
+-----------+
| Classical |
| Jazz      |
| Mlb       |
| Mls       |
| Musicals  |
| Nba       |
| Nfl       |
| Nhl       |
| Opera     |
| Plays     |
| Pop       |
+-----------+
```

スペース関数以外の英数字以外の文字を単語の区切り文字として使用するには、次の例を使用します。各文字列のいくつかの文字が大文字になります。

```
SELECT email, INITCAP(email)
FROM users
ORDER BY userid DESC LIMIT 5;

+------------------------------------+------------------------------------+
|               email                |              initcap               |
+------------------------------------+------------------------------------+
| urna.Ut@egetdictumplacerat.edu     | Urna.Ut@Egetdictumplacerat.Edu     |
| nibh.enim@egestas.ca               | Nibh.Enim@Egestas.Ca               |
| in@Donecat.ca                      | In@Donecat.Ca                      |
| sodales@blanditviverraDonec.ca     | Sodales@Blanditviverradonec.Ca     |
| sociis.natoque.penatibus@vitae.org | Sociis.Natoque.Penatibus@Vitae.Org |
+------------------------------------+------------------------------------+
```