バージョンごとのドキュメント一覧

DROP DATABASE

DROP DATABASE <refpurpose>remove a database</refpurpose> — データベースを削除する

概要

DROP DATABASE [ IF EXISTS ] name [ [ WITH ] ( option [, ...] ) ]


<phrase>where <replaceable class="parameter">option</replaceable> can be:</phrase>

ここでoptionは以下の通りです。

    FORCE

説明

<title>Description</title>

<command>DROP DATABASE</command> drops a database. It removes the catalog entries for the database and deletes the directory containing the data. It can only be executed by the database owner. It cannot be executed while you are connected to the target database. (Connect to <literal>postgres</literal> or any other database to issue this command.) Also, if anyone else is connected to the target database, this command will fail unless you use the <literal>FORCE</literal> option described below. DROP DATABASEは、データベースを削除します。 そのデータベースの項目をカタログから削除し、データを保存していたディレクトリを削除します。 データベースの所有者のみがこのコマンドを実行することができます。 対象とするデータベースに接続している時は実行できません (このコマンドを実行する時は、postgresや他のデータベースに接続してください)。 また、他のユーザが対象とするデータベースに接続している時は、以下に書かれたFORCEオプションを使わない限り、このコマンドは失敗します。

<command>DROP DATABASE</command> cannot be undone. Use it with care! DROP DATABASEは元に戻すことができません。 十分注意して使用してください。

パラメータ

<title>Parameters</title>
IF EXISTS

Do not throw an error if the database does not exist. A notice is issued in this case. データベースが存在しない場合でもエラーになりません。 この場合注意メッセージが発行されます。

name

The name of the database to remove. 削除するデータベースの名前です。

FORCE

Attempt to terminate all existing connections to the target database. It doesn't terminate if prepared transactions, active logical replication slots or subscriptions are present in the target database. 対象とするデータベースへの既存の接続をすべて終了することを試みます。 対象とするデータベースにプリペアドトランザクション、実行中の論理レプリケーションスロット、サブスクリプションが存在する場合には終了しません。

This will fail if the current user has no permissions to terminate other connections. Required permissions are the same as with <literal>pg_terminate_backend</literal>, described in <xref linkend="functions-admin-signal"/>. This will also fail if we are not able to terminate connections. これは、現在のユーザに他の接続を終了する権限がない場合には失敗します。 要求される権限は、9.27.2に書かれているpg_terminate_backendと同じです。 これは接続を終了できない場合も失敗します。

注釈

<title>Notes</title>

<command>DROP DATABASE</command> cannot be executed inside a transaction block. DROP DATABASEはトランザクションブロックの内部では実行できません。

This command cannot be executed while connected to the target database. Thus, it might be more convenient to use the program <xref linkend="app-dropdb"/> instead, which is a wrapper around this command. 対象とするデータベースに接続している間は、このコマンドを実行することができません。 したがって、このコマンドのラッパーであるdropdbプログラムを使用する方がより便利かもしれません。

互換性

<title>Compatibility</title>

There is no <command>DROP DATABASE</command> statement in the SQL standard. 標準SQLにはDROP DATABASE文はありません。

関連項目

<title>See Also</title> CREATE DATABASE