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

DROP PROCEDURE

DROP PROCEDURE <refpurpose>remove a procedure</refpurpose> — プロシージャを削除する

概要

DROP PROCEDURE [ IF EXISTS ] name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] [, ...]
    [ CASCADE | RESTRICT ]

説明

<title>Description</title>

<command>DROP PROCEDURE</command> removes the definition of one or more existing procedures. To execute this command the user must be the owner of the procedure(s). The argument types to the procedure(s) usually must be specified, since several different procedures can exist with the same name and different argument lists. DROP PROCEDUREは1つ以上の既存のプロシージャ定義を削除します。 このコマンドを実行できるのは、そのプロシージャの所有者のみです。 プロシージャの引数の型は通常必ず指定しなければなりません。 異なる引数を持つ同じ名前のプロシージャが複数存在する可能性があるからです。

パラメータ

<title>Parameters</title>
IF EXISTS

Do not throw an error if the procedure does not exist. A notice is issued in this case. プロシージャが存在しない場合でもエラーになりません。 この場合注意(NOTICE)メッセージが発行されます。

name

The name (optionally schema-qualified) of an existing procedure. 既存の関数の名前です(スキーマ修飾名も可)。

argmode

The mode of an argument: <literal>IN</literal>, <literal>OUT</literal>, <literal>INOUT</literal>, or <literal>VARIADIC</literal>. If omitted, the default is <literal>IN</literal> (but see below). 引数モードで、INOUTINOUTVARIADICのいずれかです。 省略した場合のデフォルトはINです(ただし、以下を参照)。

argname

The name of an argument. Note that <command>DROP PROCEDURE</command> does not actually pay any attention to argument names, since only the argument data types are used to determine the procedure's identity. 引数の名前です。 プロシージャの識別を行うには引数のデータ型のみが使用されますので、実際にはDROP PROCEDUREは引数の名前を無視することに注意してください。

argtype

The data type(s) of the procedure's arguments (optionally schema-qualified), if any. See below for details. もしあれば、そのプロシージャの引数のデータ型(スキーマ修飾可能)です。 詳細は以下を参照してください。

CASCADE

Automatically drop objects that depend on the procedure, and in turn all objects that depend on those objects (see <xref linkend="ddl-depend"/>). プロシージャに依存するオブジェクトを自動的に削除し、さらにそれらのオブジェクトに依存するすべてのオブジェクトも削除します(5.14参照)。

RESTRICT

Refuse to drop the procedure if any objects depend on it. This is the default. 依存しているオブジェクトがある場合、そのプロシージャの削除を拒否します。 これがデフォルトです。

注釈

<title>Notes</title>

If there is only one procedure of the given name, the argument list can be omitted. Omit the parentheses too in this case. 指定した名前のプロシージャが1つしかない場合は、引数リストを省略できます。 この場合は括弧も省略してください。

In <productname>PostgreSQL</productname>, it's sufficient to list the input (including <literal>INOUT</literal>) arguments, because no two routines of the same name are allowed to share the same input-argument list. Moreover, the <command>DROP</command> command will not actually check that you wrote the types of <literal>OUT</literal> arguments correctly; so any arguments that are explicitly marked <literal>OUT</literal> are just noise. But writing them is recommendable for consistency with the corresponding <command>CREATE</command> command. PostgreSQLでは、入力引数(INOUTを含む)を列挙すれば十分です。 これは同じ名前のルーチンが同じ入力引数リストを共有することは許可されていないためです。 さらにDROPコマンドはOUT引数の型を正しく書いたかどうかを実際にはチェックしません。 したがって、明示的にOUTと記された引数は単なるノイズにすぎません。 しかし、対応するCREATEコマンドとの一貫性を保つために、これらを書いておくことをお勧めします。

For compatibility with the SQL standard, it is also allowed to write all the argument data types (including those of <literal>OUT</literal> arguments) without any <replaceable class="parameter">argmode</replaceable> markers. When this is done, the types of the procedure's <literal>OUT</literal> argument(s) <emphasis>will</emphasis> be verified against the command. This provision creates an ambiguity, in that when the argument list contains no <replaceable class="parameter">argmode</replaceable> markers, it's unclear which rule is intended. The <command>DROP</command> command will attempt the lookup both ways, and will throw an error if two different procedures are found. To avoid the risk of such ambiguity, it's recommendable to write <literal>IN</literal> markers explicitly rather than letting them be defaulted, thus forcing the traditional <productname>PostgreSQL</productname> interpretation to be used. SQL標準との互換性のため、argmode印を付けずに、すべての引数のデータ型(OUT引数のデータ型を含む)を書くこともできます。 これが行なわれると、プロシージャのOUT引数の型はコマンドに対して検証されるようになるでしょう。 この規定は、引数リストにargmode印が含まれていない場合、どの規則を意図しているのかが不明確であるという曖昧さを生じさせます。 DROPコマンドは両方の方法で検索を試み、2つの異なるプロシージャが見つかった場合エラーを生じます。 このような曖昧さのリスクを避けるために、IN印をデフォルトにするのではなく明示的に記述して、従来のPostgreSQL解釈を強制的に使用することをお勧めします。

The lookup rules just explained are also used by other commands that act on existing procedures, such as <command>ALTER PROCEDURE</command> and <command>COMMENT ON PROCEDURE</command>. ここで説明した検索規則は、ALTER PROCEDURECOMMENT ON PROCEDUREなど、既存のプロシージャーに作用する他のコマンドでも使用されます。

<title>Examples</title>

If there is only one procedure <literal>do_db_maintenance</literal>, this command is sufficient to drop it: do_db_maintenanceプロシージャが1つしかない場合、次のコマンドで削除できます。

DROP PROCEDURE do_db_maintenance;

Given this procedure definition: 下記のプロシージャ定義が与えられた時、

CREATE PROCEDURE do_db_maintenance(IN target_schema text, OUT results text) ...

any one of these commands would work to drop it: 下記のコマンドのいずれかを使用すれば、プロシージャを削除することができます。

DROP PROCEDURE do_db_maintenance(IN target_schema text, OUT results text);
DROP PROCEDURE do_db_maintenance(IN text, OUT text);
DROP PROCEDURE do_db_maintenance(IN text);
DROP PROCEDURE do_db_maintenance(text);
DROP PROCEDURE do_db_maintenance(text, text);  -- potentially ambiguous

However, the last example would be ambiguous if there is also, say, しかし、最後の例は、例えば下記もあると曖昧になります。

CREATE PROCEDURE do_db_maintenance(IN target_schema text, IN options text) ...

互換性

<title>Compatibility</title>

This command conforms to the SQL standard, with these <productname>PostgreSQL</productname> extensions: このコマンドはSQL標準に準拠しますが、以下のPostgreSQLの拡張があります。

  • <para>The standard only allows one procedure to be dropped per command.</para>

    標準はコマンドごとに一つのプロシージャしか削除できません。

  • <para>The <literal>IF EXISTS</literal> option is an extension.</para>

    IF EXISTSオプションは拡張です。

  • <para>The ability to specify argument modes and names is an extension, and the lookup rules differ when modes are given.</para>

    引数モードと引数名を指定できるのは拡張で、モードが指定されている場合は検索規則が異なります。

関連項目

<title>See Also</title> CREATE PROCEDURE, ALTER PROCEDURE, DROP FUNCTION, DROP ROUTINE