gooderp18绿色标准版
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

125 行
12KB

  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 V1.79.1" /><link rel="prev" href="sql-alterpolicy.html" title="ALTER POLICY" /><link rel="next" href="sql-alterpublication.html" title="ALTER PUBLICATION" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" 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 12.4 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></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">
  3. ALTER 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 ]
  5. ALTER 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>
  7. ALTER 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_USER | SESSION_USER }
  9. ALTER 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>
  11. ALTER 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. DEPENDS ON EXTENSION <em class="replaceable"><code>extension_name</code></em>
  13. <span class="phrase">where <em class="replaceable"><code>action</code></em> is one of:</span>
  14. [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER
  15. SET <em class="replaceable"><code>configuration_parameter</code></em> { TO | = } { <em class="replaceable"><code>value</code></em> | DEFAULT }
  16. SET <em class="replaceable"><code>configuration_parameter</code></em> FROM CURRENT
  17. RESET <em class="replaceable"><code>configuration_parameter</code></em>
  18. RESET ALL
  19. </pre></div><div class="refsect1" id="id-1.9.3.24.5"><h2>Description</h2><p>
  20. <code class="command">ALTER PROCEDURE</code> changes the definition of a
  21. procedure.
  22. </p><p>
  23. You must own the procedure to use <code class="command">ALTER PROCEDURE</code>.
  24. To change a procedure's schema, you must also have <code class="literal">CREATE</code>
  25. privilege on the new schema.
  26. To alter the owner, you must also be a direct or indirect member of the new
  27. owning role, and that role must have <code class="literal">CREATE</code> privilege on
  28. the procedure's schema. (These restrictions enforce that altering the owner
  29. doesn't do anything you couldn't do by dropping and recreating the procedure.
  30. However, a superuser can alter ownership of any procedure anyway.)
  31. </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>
  32. The name (optionally schema-qualified) of an existing procedure. If no
  33. argument list is specified, the name must be unique in its schema.
  34. </p></dd><dt><span class="term"><em class="replaceable"><code>argmode</code></em></span></dt><dd><p>
  35. The mode of an argument: <code class="literal">IN</code> or <code class="literal">VARIADIC</code>.
  36. If omitted, the default is <code class="literal">IN</code>.
  37. </p></dd><dt><span class="term"><em class="replaceable"><code>argname</code></em></span></dt><dd><p>
  38. The name of an argument.
  39. Note that <code class="command">ALTER PROCEDURE</code> does not actually pay
  40. any attention to argument names, since only the argument data
  41. types are needed to determine the procedure's identity.
  42. </p></dd><dt><span class="term"><em class="replaceable"><code>argtype</code></em></span></dt><dd><p>
  43. The data type(s) of the procedure's arguments (optionally
  44. schema-qualified), if any.
  45. </p></dd><dt><span class="term"><em class="replaceable"><code>new_name</code></em></span></dt><dd><p>
  46. The new name of the procedure.
  47. </p></dd><dt><span class="term"><em class="replaceable"><code>new_owner</code></em></span></dt><dd><p>
  48. The new owner of the procedure. Note that if the procedure is
  49. marked <code class="literal">SECURITY DEFINER</code>, it will subsequently
  50. execute as the new owner.
  51. </p></dd><dt><span class="term"><em class="replaceable"><code>new_schema</code></em></span></dt><dd><p>
  52. The new schema for the procedure.
  53. </p></dd><dt><span class="term"><em class="replaceable"><code>extension_name</code></em></span></dt><dd><p>
  54. The name of the extension that the procedure is to depend on.
  55. </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>
  56. Change whether the procedure is a security definer or not. The
  57. key word <code class="literal">EXTERNAL</code> is ignored for SQL
  58. conformance. See <a class="xref" href="sql-createprocedure.html" title="CREATE PROCEDURE"><span class="refentrytitle">CREATE PROCEDURE</span></a> for more information about
  59. this capability.
  60. </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>
  61. Add or change the assignment to be made to a configuration parameter
  62. when the procedure is called. If
  63. <em class="replaceable"><code>value</code></em> is <code class="literal">DEFAULT</code>
  64. or, equivalently, <code class="literal">RESET</code> is used, the procedure-local
  65. setting is removed, so that the procedure executes with the value
  66. present in its environment. Use <code class="literal">RESET
  67. ALL</code> to clear all procedure-local settings.
  68. <code class="literal">SET FROM CURRENT</code> saves the value of the parameter that
  69. is current when <code class="command">ALTER PROCEDURE</code> is executed as the value
  70. to be applied when the procedure is entered.
  71. </p><p>
  72. See <a class="xref" href="sql-set.html" title="SET"><span class="refentrytitle">SET</span></a> and
  73. <a class="xref" href="runtime-config.html" title="Chapter 19. Server Configuration">Chapter 19</a>
  74. for more information about allowed parameter names and values.
  75. </p></dd><dt><span class="term"><code class="literal">RESTRICT</code></span></dt><dd><p>
  76. Ignored for conformance with the SQL standard.
  77. </p></dd></dl></div></div><div class="refsect1" id="id-1.9.3.24.7"><h2>Examples</h2><p>
  78. To rename the procedure <code class="literal">insert_data</code> with two arguments
  79. of type <code class="type">integer</code> to <code class="literal">insert_record</code>:
  80. </p><pre class="programlisting">
  81. ALTER PROCEDURE insert_data(integer, integer) RENAME TO insert_record;
  82. </pre><p>
  83. </p><p>
  84. To change the owner of the procedure <code class="literal">insert_data</code> with
  85. two arguments of type <code class="type">integer</code> to <code class="literal">joe</code>:
  86. </p><pre class="programlisting">
  87. ALTER PROCEDURE insert_data(integer, integer) OWNER TO joe;
  88. </pre><p>
  89. </p><p>
  90. To change the schema of the procedure <code class="literal">insert_data</code> with
  91. two arguments of type <code class="type">integer</code>
  92. to <code class="literal">accounting</code>:
  93. </p><pre class="programlisting">
  94. ALTER PROCEDURE insert_data(integer, integer) SET SCHEMA accounting;
  95. </pre><p>
  96. </p><p>
  97. To mark the procedure <code class="literal">insert_data(integer, integer)</code> as
  98. being dependent on the extension <code class="literal">myext</code>:
  99. </p><pre class="programlisting">
  100. ALTER PROCEDURE insert_data(integer, integer) DEPENDS ON EXTENSION myext;
  101. </pre><p>
  102. </p><p>
  103. To adjust the search path that is automatically set for a procedure:
  104. </p><pre class="programlisting">
  105. ALTER PROCEDURE check_password(text) SET search_path = admin, pg_temp;
  106. </pre><p>
  107. </p><p>
  108. To disable automatic setting of <code class="varname">search_path</code> for a procedure:
  109. </p><pre class="programlisting">
  110. ALTER PROCEDURE check_password(text) RESET search_path;
  111. </pre><p>
  112. The procedure will now execute with whatever search path is used by its
  113. caller.
  114. </p></div><div class="refsect1" id="id-1.9.3.24.8"><h2>Compatibility</h2><p>
  115. This statement is partially compatible with the <code class="command">ALTER
  116. PROCEDURE</code> statement in the SQL standard. The standard allows more
  117. properties of a procedure to be modified, but does not provide the
  118. ability to rename a procedure, make a procedure a security definer,
  119. attach configuration parameter values to a procedure,
  120. or change the owner, schema, or volatility of a procedure. The standard also
  121. requires the <code class="literal">RESTRICT</code> key word, which is optional in
  122. <span class="productname">PostgreSQL</span>.
  123. </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">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sql-commands.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sql-alterpublication.html">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">Home</a></td><td width="40%" align="right" valign="top"> ALTER PUBLICATION</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1