Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
sql-alterprocedure.html134 linesDownload Raw Back to html
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>ALTER PROCEDURE</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="sql-alterpolicy.html" title="ALTER POLICY" /><link rel="next" href="sql-alterpublication.html" title="ALTER PUBLICATION" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">ALTER PROCEDURE</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sql-alterpolicy.html" title="ALTER POLICY">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><th width="60%" align="center">SQL Commands</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="sql-alterpublication.html" title="ALTER PUBLICATION">Next</a></td></tr></table><hr /></div><div class="refentry" id="SQL-ALTERPROCEDURE"><div class="titlepage"></div><a id="id-1.9.3.24.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">ALTER PROCEDURE</span></h2><p>ALTER PROCEDURE — change the definition of a procedure</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">3ALTER PROCEDURE <em class="replaceable"><code>name</code></em> [ ( [ [ <em class="replaceable"><code>argmode</code></em> ] [ <em class="replaceable"><code>argname</code></em> ] <em class="replaceable"><code>argtype</code></em> [, ...] ] ) ]4    <em class="replaceable"><code>action</code></em> [ ... ] [ RESTRICT ]5ALTER PROCEDURE <em class="replaceable"><code>name</code></em> [ ( [ [ <em class="replaceable"><code>argmode</code></em> ] [ <em class="replaceable"><code>argname</code></em> ] <em class="replaceable"><code>argtype</code></em> [, ...] ] ) ]6    RENAME TO <em class="replaceable"><code>new_name</code></em>7ALTER PROCEDURE <em class="replaceable"><code>name</code></em> [ ( [ [ <em class="replaceable"><code>argmode</code></em> ] [ <em class="replaceable"><code>argname</code></em> ] <em class="replaceable"><code>argtype</code></em> [, ...] ] ) ]8    OWNER TO { <em class="replaceable"><code>new_owner</code></em> | CURRENT_ROLE | CURRENT_USER | SESSION_USER }9ALTER PROCEDURE <em class="replaceable"><code>name</code></em> [ ( [ [ <em class="replaceable"><code>argmode</code></em> ] [ <em class="replaceable"><code>argname</code></em> ] <em class="replaceable"><code>argtype</code></em> [, ...] ] ) ]10    SET SCHEMA <em class="replaceable"><code>new_schema</code></em>11ALTER PROCEDURE <em class="replaceable"><code>name</code></em> [ ( [ [ <em class="replaceable"><code>argmode</code></em> ] [ <em class="replaceable"><code>argname</code></em> ] <em class="replaceable"><code>argtype</code></em> [, ...] ] ) ]12    [ NO ] DEPENDS ON EXTENSION <em class="replaceable"><code>extension_name</code></em>13 14<span class="phrase">where <em class="replaceable"><code>action</code></em> is one of:</span>15 16    [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER17    SET <em class="replaceable"><code>configuration_parameter</code></em> { TO | = } { <em class="replaceable"><code>value</code></em> | DEFAULT }18    SET <em class="replaceable"><code>configuration_parameter</code></em> FROM CURRENT19    RESET <em class="replaceable"><code>configuration_parameter</code></em>20    RESET ALL21</pre></div><div class="refsect1" id="id-1.9.3.24.5"><h2>Description</h2><p>22   <code class="command">ALTER PROCEDURE</code> changes the definition of a23   procedure.24  </p><p>25   You must own the procedure to use <code class="command">ALTER PROCEDURE</code>.26   To change a procedure's schema, you must also have <code class="literal">CREATE</code>27   privilege on the new schema.28   To alter the owner, you must be able to <code class="literal">SET ROLE</code> to the29   new owning role, and that role must have <code class="literal">CREATE</code>30   privilege on the procedure's schema.31   (These restrictions enforce that altering the owner32   doesn't do anything you couldn't do by dropping and recreating the procedure.33   However, a superuser can alter ownership of any procedure anyway.)34  </p></div><div class="refsect1" id="id-1.9.3.24.6"><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>name</code></em></span></dt><dd><p>35      The name (optionally schema-qualified) of an existing procedure.  If no36      argument list is specified, the name must be unique in its schema.37     </p></dd><dt><span class="term"><em class="replaceable"><code>argmode</code></em></span></dt><dd><p>38      The mode of an argument: <code class="literal">IN</code>, <code class="literal">OUT</code>,39      <code class="literal">INOUT</code>, or <code class="literal">VARIADIC</code>.  If omitted,40      the default is <code class="literal">IN</code>.41     </p></dd><dt><span class="term"><em class="replaceable"><code>argname</code></em></span></dt><dd><p>42      The name of an argument.43      Note that <code class="command">ALTER PROCEDURE</code> does not actually pay44      any attention to argument names, since only the argument data45      types are used to determine the procedure's identity.46     </p></dd><dt><span class="term"><em class="replaceable"><code>argtype</code></em></span></dt><dd><p>47      The data type(s) of the procedure's arguments (optionally48      schema-qualified), if any.49      See <a class="xref" href="sql-dropprocedure.html" title="DROP PROCEDURE"><span class="refentrytitle">DROP PROCEDURE</span></a> for the details of how50      the procedure is looked up using the argument data type(s).51     </p></dd><dt><span class="term"><em class="replaceable"><code>new_name</code></em></span></dt><dd><p>52      The new name of the procedure.53     </p></dd><dt><span class="term"><em class="replaceable"><code>new_owner</code></em></span></dt><dd><p>54      The new owner of the procedure.  Note that if the procedure is55      marked <code class="literal">SECURITY DEFINER</code>, it will subsequently56      execute as the new owner.57     </p></dd><dt><span class="term"><em class="replaceable"><code>new_schema</code></em></span></dt><dd><p>58      The new schema for the procedure.59     </p></dd><dt><span class="term"><em class="replaceable"><code>extension_name</code></em></span></dt><dd><p>60      This form marks the procedure as dependent on the extension, or no longer61      dependent on the extension if <code class="literal">NO</code> is specified.62      A procedure that's marked as dependent on an extension is dropped when the63      extension is dropped, even if cascade is not specified.64      A procedure can depend upon multiple extensions, and will be dropped when65      any one of those extensions is dropped.66     </p></dd><dt><span class="term"><code class="literal">[<span class="optional"> EXTERNAL </span>] SECURITY INVOKER</code><br /></span><span class="term"><code class="literal">[<span class="optional"> EXTERNAL </span>] SECURITY DEFINER</code></span></dt><dd><p>67      Change whether the procedure is a security definer or not. The68      key word <code class="literal">EXTERNAL</code> is ignored for SQL69      conformance. See <a class="xref" href="sql-createprocedure.html" title="CREATE PROCEDURE"><span class="refentrytitle">CREATE PROCEDURE</span></a> for more information about70      this capability.71     </p></dd><dt><span class="term"><em class="replaceable"><code>configuration_parameter</code></em><br /></span><span class="term"><em class="replaceable"><code>value</code></em></span></dt><dd><p>72        Add or change the assignment to be made to a configuration parameter73        when the procedure is called.  If74        <em class="replaceable"><code>value</code></em> is <code class="literal">DEFAULT</code>75        or, equivalently, <code class="literal">RESET</code> is used, the procedure-local76        setting is removed, so that the procedure executes with the value77        present in its environment.  Use <code class="literal">RESET78        ALL</code> to clear all procedure-local settings.79        <code class="literal">SET FROM CURRENT</code> saves the value of the parameter that80        is current when <code class="command">ALTER PROCEDURE</code> is executed as the value81        to be applied when the procedure is entered.82       </p><p>83        See <a class="xref" href="sql-set.html" title="SET"><span class="refentrytitle">SET</span></a> and84        <a class="xref" href="runtime-config.html" title="Chapter 20. Server Configuration">Chapter 20</a>85        for more information about allowed parameter names and values.86       </p></dd><dt><span class="term"><code class="literal">RESTRICT</code></span></dt><dd><p>87      Ignored for conformance with the SQL standard.88     </p></dd></dl></div></div><div class="refsect1" id="id-1.9.3.24.7"><h2>Examples</h2><p>89   To rename the procedure <code class="literal">insert_data</code> with two arguments90   of type <code class="type">integer</code> to <code class="literal">insert_record</code>:91</p><pre class="programlisting">92ALTER PROCEDURE insert_data(integer, integer) RENAME TO insert_record;93</pre><p>94  </p><p>95   To change the owner of the procedure <code class="literal">insert_data</code> with96   two arguments of type <code class="type">integer</code> to <code class="literal">joe</code>:97</p><pre class="programlisting">98ALTER PROCEDURE insert_data(integer, integer) OWNER TO joe;99</pre><p>100  </p><p>101   To change the schema of the procedure <code class="literal">insert_data</code> with102   two arguments of type <code class="type">integer</code>103   to <code class="literal">accounting</code>:104</p><pre class="programlisting">105ALTER PROCEDURE insert_data(integer, integer) SET SCHEMA accounting;106</pre><p>107  </p><p>108   To mark the procedure <code class="literal">insert_data(integer, integer)</code> as109   being dependent on the extension <code class="literal">myext</code>:110</p><pre class="programlisting">111ALTER PROCEDURE insert_data(integer, integer) DEPENDS ON EXTENSION myext;112</pre><p>113  </p><p>114   To adjust the search path that is automatically set for a procedure:115</p><pre class="programlisting">116ALTER PROCEDURE check_password(text) SET search_path = admin, pg_temp;117</pre><p>118  </p><p>119   To disable automatic setting of <code class="varname">search_path</code> for a procedure:120</p><pre class="programlisting">121ALTER PROCEDURE check_password(text) RESET search_path;122</pre><p>123   The procedure will now execute with whatever search path is used by its124   caller.125  </p></div><div class="refsect1" id="id-1.9.3.24.8"><h2>Compatibility</h2><p>126   This statement is partially compatible with the <code class="command">ALTER127   PROCEDURE</code> statement in the SQL standard. The standard allows more128   properties of a procedure to be modified, but does not provide the129   ability to rename a procedure, make a procedure a security definer,130   attach configuration parameter values to a procedure,131   or change the owner, schema, or volatility of a procedure. The standard also132   requires the <code class="literal">RESTRICT</code> key word, which is optional in133   <span class="productname">PostgreSQL</span>.134  </p></div><div class="refsect1" id="id-1.9.3.24.9"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sql-createprocedure.html" title="CREATE PROCEDURE"><span class="refentrytitle">CREATE PROCEDURE</span></a>, <a class="xref" href="sql-dropprocedure.html" title="DROP PROCEDURE"><span class="refentrytitle">DROP PROCEDURE</span></a>, <a class="xref" href="sql-alterfunction.html" title="ALTER FUNCTION"><span class="refentrytitle">ALTER FUNCTION</span></a>, <a class="xref" href="sql-alterroutine.html" title="ALTER ROUTINE"><span class="refentrytitle">ALTER ROUTINE</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sql-alterpolicy.html" title="ALTER POLICY">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sql-alterpublication.html" title="ALTER PUBLICATION">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ALTER POLICY </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> ALTER PUBLICATION</td></tr></table></div></body></html>
codekingpro/portable-devtools · Team Ai