{"Entry":{"collection":"sql","key":"execute","name":"EXECUTE","aliases":["execute"],"metadata":{"aliases":["execute"],"changed_in":["8.2"],"changes":[{"from":"7.2","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"added","synopsis":null,"to":"7.3"},{"from":"7.3","purpose_changed":true,"renamed":null,"sections":{"added":["parameters"],"changed":["description","compatibility"],"removed":[]},"status":"changed","synopsis":null,"to":"7.4"},{"from":"7.4","purpose_changed":false,"renamed":null,"sections":{"added":["outputs","examples","see_also"],"changed":[],"removed":[]},"status":"changed","synopsis":null,"to":"8.0"},{"from":"8.1","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters"],"removed":[]},"status":"changed","synopsis":{"added":["EXECUTE name [ (parameter [, ...] ) ]"],"removed":["EXECUTE plan_name [ (parameter [, ...] ) ]"]},"to":"8.2"},{"from":"12","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["examples"],"removed":[]},"status":"changed","synopsis":null,"to":"13"}],"content_hash":"de2730d2da2f284c70aab606c36893c20d166bb4f57dc02a5d61c47f5de74cbd","editorial":{},"first_version":"7.3","group":"cursor","imported_at":"2026-09-30T17:43:39.219401+08:00","last_version":"20","name":"EXECUTE","object":"","position":12003,"present_in":["7.3","7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"purpose":"execute a prepared statement","purpose_zh":"","related":["deallocate","prepare"],"slug":"execute","source_rev":"a709ab85","synopsis":"EXECUTE name [ ( parameter [, ...] ) ]","verb":"EXECUTE"}},"Definition":{"Collection":"sql","Key":"execute","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"execute","SourceRevision":"a709ab85","Facts":{"anchor":"SQL-EXECUTE","file":"sql-execute.html","lang":"en","name":"EXECUTE","purpose":"execute a prepared statement","purpose_zh":"","related":["deallocate","prepare"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e is used to execute a previously prepared statement. Since prepared statements only exist for the duration of a session, the prepared statement must have been created by a \u003ccode class=\"command\"\u003ePREPARE\u003c/code\u003e statement executed earlier in the current session.\u003c/p\u003e\u003cp\u003eIf the \u003ccode class=\"command\"\u003ePREPARE\u003c/code\u003e statement that created the statement specified some parameters, a compatible set of parameters must be passed to the \u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e statement, or else an error is raised. Note that (unlike functions) prepared statements are not overloaded based on the type or number of their parameters; the name of a prepared statement must be unique within a database session.\u003c/p\u003e\u003cp\u003eFor more information on the creation and usage of prepared statements, see \u003ca href=\"/docs/18/sql-prepare.html\" title=\"PREPARE\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE\u003c/span\u003e\u003c/a\u003e.\u003c/p\u003e","key":"description","title":"Description"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe name of the prepared statement to execute.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe actual value of a parameter to the prepared statement. This must be an expression yielding a value that is compatible with the data type of this parameter, as was determined when the prepared statement was created.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003eThe command tag returned by \u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e is that of the prepared statement, and not \u003ccode class=\"literal\"\u003eEXECUTE\u003c/code\u003e.\u003c/p\u003e","key":"outputs","title":"Outputs"},{"html":"\u003cp\u003eExamples are given in \u003ca href=\"/docs/18/sql-prepare.html#SQL-PREPARE-EXAMPLES\" title=\"Examples\"\u003eExamples\u003c/a\u003e in the \u003ca href=\"/docs/18/sql-prepare.html\" title=\"PREPARE\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE\u003c/span\u003e\u003c/a\u003e documentation.\u003c/p\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003eThe SQL standard includes an \u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e statement, but it is only for use in embedded SQL. This version of the \u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e statement also uses a somewhat different syntax.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/deallocate/?v=18\" title=\"DEALLOCATE\"\u003e\u003cspan class=\"refentrytitle\"\u003eDEALLOCATE\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/prepare/?v=18\" title=\"PREPARE\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","slug":"18","synopsis_html":"EXECUTE \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e [ ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e [, ...] ) ]","synopsis_text":"EXECUTE name [ ( parameter [, ...] ) ]"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"execute","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"EXECUTE","Summary":"执行一个预备语句","BodyHTML":"\u003cpre\u003eEXECUTE name [ ( parameter [, ...] ) ]\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eEXECUTE\u003c/code\u003e用于执行一个先前创建的预备语句。由于预备语句只在一个会话期间内存在，因此该预备语句必须由当前会话中较早执行的\u003ccode\u003ePREPARE\u003c/code\u003e语句创建。\u003c/p\u003e\u003cp\u003e如果创建该语句的\u003ccode\u003ePREPARE\u003c/code\u003e语句指定了某些参数，那么传递给\u003ccode\u003eEXECUTE\u003c/code\u003e语句的参数集合就必须与之兼容，否则将引发错误。注意，预备语句（不同于函数）不会根据其参数的类型或个数进行重载；预备语句的名称在一个数据库会话内必须唯一。\u003c/p\u003e\u003cp\u003e有关预备语句的创建和用法的更多信息，请参见\u003ca href=\"/docs/18/sql-prepare.html\" title=\"PREPARE\" rel=\"nofollow\"\u003e\u003cspan\u003ePREPARE\u003c/span\u003e\u003c/a\u003e。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e参数\u003c/h2\u003e\u003cdiv\u003e\u003cdl\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e要执行的预备语句名称。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e预备语句中某个参数的实际值。它必须是一个表达式，并且其求值结果必须与该参数的数据类型兼容，该数据类型在创建预备语句时已确定。\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e输出\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eEXECUTE\u003c/code\u003e返回的命令标签是该预备语句的命令标签，而不是\u003ccode\u003eEXECUTE\u003c/code\u003e。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e示例\u003c/h2\u003e\u003cp\u003e示例见\u003ca href=\"/docs/18/sql-prepare.html\" title=\"PREPARE\" rel=\"nofollow\"\u003e\u003cspan\u003ePREPARE\u003c/span\u003e\u003c/a\u003e文档中的\u003ca href=\"/docs/18/sql-prepare.html#SQL-PREPARE-EXAMPLES\" title=\"示例\" rel=\"nofollow\"\u003e示例\u003c/a\u003e。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003eSQL 标准包含\u003ccode\u003eEXECUTE\u003c/code\u003e语句，但它只用于嵌入式 SQL。这里的\u003ccode\u003eEXECUTE\u003c/code\u003e语句还使用了稍有不同的语法。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e另见\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/wiki/sql/deallocate/?v=18\" title=\"DEALLOCATE\" rel=\"nofollow\"\u003e\u003cspan\u003eDEALLOCATE\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/prepare/?v=18\" title=\"PREPARE\" rel=\"nofollow\"\u003e\u003cspan\u003ePREPARE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","SourceRevision":"1b5ca64c","ContentHash":"8255564bd5c8c5c49f2b7e20bcd4d2d9cfa0cf2fa3e59281839b9ea5d54f7483","Payload":{"purpose_zh":"执行一个预备语句","sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e用于执行一个先前创建的预备语句。由于预备语句只在一个会话期间内存在，因此该预备语句必须由当前会话中较早执行的\u003ccode class=\"command\"\u003ePREPARE\u003c/code\u003e语句创建。\u003c/p\u003e\u003cp\u003e如果创建该语句的\u003ccode class=\"command\"\u003ePREPARE\u003c/code\u003e语句指定了某些参数，那么传递给\u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e语句的参数集合就必须与之兼容，否则将引发错误。注意，预备语句（不同于函数）不会根据其参数的类型或个数进行重载；预备语句的名称在一个数据库会话内必须唯一。\u003c/p\u003e\u003cp\u003e有关预备语句的创建和用法的更多信息，请参见\u003ca href=\"/docs/18/sql-prepare.html\" title=\"PREPARE\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE\u003c/span\u003e\u003c/a\u003e。\u003c/p\u003e","key":"description","title":"描述"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e要执行的预备语句名称。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e预备语句中某个参数的实际值。它必须是一个表达式，并且其求值结果必须与该参数的数据类型兼容，该数据类型在创建预备语句时已确定。\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"参数"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e返回的命令标签是该预备语句的命令标签，而不是\u003ccode class=\"literal\"\u003eEXECUTE\u003c/code\u003e。\u003c/p\u003e","key":"outputs","title":"输出"},{"html":"\u003cp\u003e示例见\u003ca href=\"/docs/18/sql-prepare.html\" title=\"PREPARE\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE\u003c/span\u003e\u003c/a\u003e文档中的\u003ca href=\"/docs/18/sql-prepare.html#SQL-PREPARE-EXAMPLES\" title=\"示例\"\u003e示例\u003c/a\u003e。\u003c/p\u003e","key":"examples","title":"示例"},{"html":"\u003cp\u003eSQL 标准包含\u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e语句，但它只用于嵌入式 SQL。这里的\u003ccode class=\"command\"\u003eEXECUTE\u003c/code\u003e语句还使用了稍有不同的语法。\u003c/p\u003e","key":"compatibility","title":"兼容性"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/deallocate/?v=18\" title=\"DEALLOCATE\"\u003e\u003cspan class=\"refentrytitle\"\u003eDEALLOCATE\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/prepare/?v=18\" title=\"PREPARE\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"另见"}],"sections_same_as":"","synopsis_html":"EXECUTE \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e [ ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e [, ...] ) ]","synopsis_text":"EXECUTE name [ ( parameter [, ...] ) ]"}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","7.3","7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
