---
title: "PostgreSQL 固有のデータベース関数"
version: 6.1
locale: ja
source: https://docs.djangoproject.com/ja/6.1/ref/contrib/postgres/functions/
canonical: https://djangodocs.dev/ja/6.1/ref/contrib/postgres/functions/
---
# PostgreSQL 固有のデータベース関数

これらの関数はすべて `django.contrib.postgres.functions` モジュールから利用できます。

## `RandomUUID`

#### `class RandomUUID`

バージョン 4 の UUID を返します。

使用例:

```pycon
>>> from django.contrib.postgres.functions import RandomUUID
>>> Article.objects.update(uuid=RandomUUID())
```

> **Use django.db.models.functions.UUID4 instead.**
>
> [`django.db.models.functions.UUID4`](/ja/6.1/ref/models/database-functions/#django.db.models.functions.UUID4) is a cross-database version of
> this function. `RandomUUID` may be deprecated in the future.

## `TransactionNow`

#### `class TransactionNow`

現在のトランザクションが開始されたデータベースサーバー上の日時を返します。トランザクション中でない場合は、現在のステートメントの日時を返します。これは [`django.db.models.functions.Now`](/ja/6.1/ref/models/database-functions/#django.db.models.functions.Now) を補完するもので、現在のステートメントの日時を返します。

Note that only the outermost call to [`atomic()`](/ja/6.1/topics/db/transactions/#django.db.transaction.atomic)
sets up a transaction and thus sets the time that `TransactionNow()` will
return; nested calls create savepoints which do not affect the transaction
time.

使用例:

```pycon
>>> from django.contrib.postgres.functions import TransactionNow
>>> Article.objects.filter(published__lte=TransactionNow())
<QuerySet [<Article: How to Django>]>
```
