> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-fbfa8bee.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> ULID を扱う関数のドキュメント

# ULID を扱う関数

<Note>
  以下のドキュメントは、`system.functions` システムテーブルから生成されています。
</Note>

{/*AUTOGENERATED_START*/}

<div id="ULIDStringToDateTime">
  ## ULIDStringToDateTime
</div>

導入バージョン: v23.3.0

この関数は、[ULID](https://github.com/ulid/spec) からtimestampを抽出します。

**構文**

```sql theme={null}
ULIDStringToDateTime(ulid[, timezone])
```

**引数**

* `ulid` — 入力 ULID。[`String`](/ja/reference/data-types/string) または [`FixedString(26)`](/ja/reference/data-types/fixedstring)
* `timezone` — 任意。戻り値に使用するタイムゾーン名。[`String`](/ja/reference/data-types/string)

**戻り値**

ミリ秒精度のタイムスタンプ。[`DateTime64(3)`](/ja/reference/data-types/datetime64)

**例**

**使用例**

```sql title=Query theme={null}
SELECT ULIDStringToDateTime('01GNB2S2FGN2P93QPXDNB4EN2R')
```

```response title=Response theme={null}
┌─ULIDStringToDateTime('01GNB2S2FGN2P93QPXDNB4EN2R')─┐
│                            2022-12-28 00:40:37.616 │
└────────────────────────────────────────────────────┘
```

<div id="generateULID">
  ## generateULID
</div>

導入バージョン: v23.2.0

[Universally Unique Lexicographically Sortable Identifier (ULID)](https://github.com/ulid/spec) を生成します。

**構文**

```sql theme={null}
generateULID([x])
```

**引数**

* `x` — 任意。サポートされているいずれかのデータ型を返す式。返された値は破棄されますが、この関数が1つのクエリ内で複数回呼び出される場合、式自体は [共通部分式除去](/ja/reference/functions/regular-functions/overview#common-subexpression-elimination) を回避するために使用されます。[`Any`](/ja/reference/data-types/index)

**戻り値**

ULID を返します。[`FixedString(26)`](/ja/reference/data-types/fixedstring)

**例**

**使用例**

```sql title=Query theme={null}
SELECT generateULID()
```

```response title=Response theme={null}
┌─generateULID()─────────────┐
│ 01GNB2S2FGN2P93QPXDNB4EN2R │
└────────────────────────────┘
```

**1行で複数の値を生成する必要がある場合の使用例**

```sql title=Query theme={null}
SELECT generateULID(1), generateULID(2)
```

```response title=Response theme={null}
┌─generateULID(1)────────────┬─generateULID(2)────────────┐
│ 01GNB2SGG4RHKVNT9ZGA4FFMNP │ 01GNB2SGG4V0HMQVH4VBVPSSRB │
└────────────────────────────┴────────────────────────────┘
```

<div id="see-also">
  ## 関連項目
</div>

* [UUID](/ja/reference/functions/regular-functions/uuid-functions)
