1<!-- 2doc/src/sgml/ref/drop_function.sgml 3PostgreSQL documentation 4--> 5 6<refentry id="SQL-DROPFUNCTION"> 7 <indexterm zone="sql-dropfunction"> 8 <primary>DROP FUNCTION</primary> 9 </indexterm> 10 11 <refmeta> 12 <refentrytitle>DROP FUNCTION</refentrytitle> 13 <manvolnum>7</manvolnum> 14 <refmiscinfo>SQL - Language Statements</refmiscinfo> 15 </refmeta> 16 17 <refnamediv> 18 <refname>DROP FUNCTION</refname> 19 <refpurpose>remove a function</refpurpose> 20 </refnamediv> 21 22 <refsynopsisdiv> 23<synopsis> 24DROP FUNCTION [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [ ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) ] [, ...] 25 [ CASCADE | RESTRICT ] 26</synopsis> 27 </refsynopsisdiv> 28 29 <refsect1> 30 <title>Description</title> 31 32 <para> 33 <command>DROP FUNCTION</command> removes the definition of an existing 34 function. To execute this command the user must be the 35 owner of the function. The argument types to the 36 function must be specified, since several different functions 37 can exist with the same name and different argument lists. 38 </para> 39 </refsect1> 40 41 <refsect1> 42 <title>Parameters</title> 43 44 <variablelist> 45 <varlistentry> 46 <term><literal>IF EXISTS</literal></term> 47 <listitem> 48 <para> 49 Do not throw an error if the function does not exist. A notice is issued 50 in this case. 51 </para> 52 </listitem> 53 </varlistentry> 54 55 <varlistentry> 56 <term><replaceable class="parameter">name</replaceable></term> 57 <listitem> 58 <para> 59 The name (optionally schema-qualified) of an existing function. If no 60 argument list is specified, the name must be unique in its schema. 61 </para> 62 </listitem> 63 </varlistentry> 64 65 <varlistentry> 66 <term><replaceable class="parameter">argmode</replaceable></term> 67 68 <listitem> 69 <para> 70 The mode of an argument: <literal>IN</>, <literal>OUT</>, 71 <literal>INOUT</>, or <literal>VARIADIC</>. 72 If omitted, the default is <literal>IN</>. 73 Note that <command>DROP FUNCTION</command> does not actually pay 74 any attention to <literal>OUT</> arguments, since only the input 75 arguments are needed to determine the function's identity. 76 So it is sufficient to list the <literal>IN</>, <literal>INOUT</>, 77 and <literal>VARIADIC</> arguments. 78 </para> 79 </listitem> 80 </varlistentry> 81 82 <varlistentry> 83 <term><replaceable class="parameter">argname</replaceable></term> 84 85 <listitem> 86 <para> 87 The name of an argument. 88 Note that <command>DROP FUNCTION</command> does not actually pay 89 any attention to argument names, since only the argument data 90 types are needed to determine the function's identity. 91 </para> 92 </listitem> 93 </varlistentry> 94 95 <varlistentry> 96 <term><replaceable class="parameter">argtype</replaceable></term> 97 98 <listitem> 99 <para> 100 The data type(s) of the function's arguments (optionally 101 schema-qualified), if any. 102 </para> 103 </listitem> 104 </varlistentry> 105 106 <varlistentry> 107 <term><literal>CASCADE</literal></term> 108 <listitem> 109 <para> 110 Automatically drop objects that depend on the function (such as 111 operators or triggers), 112 and in turn all objects that depend on those objects 113 (see <xref linkend="ddl-depend">). 114 </para> 115 </listitem> 116 </varlistentry> 117 118 <varlistentry> 119 <term><literal>RESTRICT</literal></term> 120 <listitem> 121 <para> 122 Refuse to drop the function if any objects depend on it. This 123 is the default. 124 </para> 125 </listitem> 126 </varlistentry> 127 </variablelist> 128 </refsect1> 129 130 <refsect1 id="SQL-DROPFUNCTION-examples"> 131 <title>Examples</title> 132 133 <para> 134 This command removes the square root function: 135 136<programlisting> 137DROP FUNCTION sqrt(integer); 138</programlisting></para> 139 140 <para> 141 Drop multiple functions in one command: 142<programlisting> 143DROP FUNCTION sqrt(integer), sqrt(bigint); 144</programlisting></para> 145 146 <para> 147 If the function name is unique in its schema, it can be referred to without 148 an argument list: 149<programlisting> 150DROP FUNCTION update_employee_salaries; 151</programlisting> 152 Note that this is different from 153<programlisting> 154DROP FUNCTION update_employee_salaries(); 155</programlisting> 156 which refers to a function with zero arguments, whereas the first variant 157 can refer to a function with any number of arguments, including zero, as 158 long as the name is unique. 159 </para> 160 </refsect1> 161 162 <refsect1 id="SQL-DROPFUNCTION-compatibility"> 163 <title>Compatibility</title> 164 165 <para> 166 This command conforms to the SQL standard, with 167 these <productname>PostgreSQL</productname> extensions: 168 <itemizedlist> 169 <listitem> 170 <para>The standard only allows one function to be dropped per command.</para> 171 </listitem> 172 <listitem> 173 <para>The <literal>IF EXISTS</literal> option</para> 174 </listitem> 175 <listitem> 176 <para>The ability to specify argument modes and names</para> 177 </listitem> 178 </itemizedlist> 179 </para> 180 </refsect1> 181 182 <refsect1> 183 <title>See Also</title> 184 185 <simplelist type="inline"> 186 <member><xref linkend="sql-createfunction"></member> 187 <member><xref linkend="sql-alterfunction"></member> 188 </simplelist> 189 </refsect1> 190 191</refentry> 192