{"Entry":{"collection":"sql","key":"discard","name":"DISCARD","aliases":["discard"],"metadata":{"aliases":["discard"],"changed_in":["9.4"],"changes":[{"from":"8.2","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"added","synopsis":null,"to":"8.3"},{"from":"9.3","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description","parameters"],"removed":[]},"status":"changed","synopsis":{"added":["DISCARD { ALL | PLANS | SEQUENCES | TEMPORARY | TEMP }"],"removed":[]},"to":"9.4"},{"from":"11","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters"],"removed":[]},"status":"changed","synopsis":null,"to":"12"}],"content_hash":"e40575c9c262e3f5748e5951fd30b9a24bf661cbae8bc97a2a5a42028b4e2477","derived_content_hash":"d30bda8e9f9158399eb1d8ac0a8ff90f0001d553531ba84fa8cfe638765dc88d","editorial":{},"first_version":"8.3","group":"session","imported_at":"2026-09-27T17:57:27.35877+08:00","last_version":"20","name":"DISCARD","object":"","position":14000,"present_in":["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":"discard session state","purpose_zh":"","related":[],"repair_provenance":{"original_source_revision":"wiki-repair-20261023:96b6fd12acb872ccfab832a5b56f92ff1bbfe05613bb13856e42082f20e31adc","receipt_sha256":"836f4d9b7cf998e2c7530ba0e97f558cffd07ebfb48dc109a029319a1fd3a1ab","repair":"wiki-repair-20261023"},"slug":"discard","source_rev":"wiki-repair-20261023:a47272e51ee2dd74658651b66c2d7748eff75d701cb42fc82112aefd760ed857","synopsis":"DISCARD { ALL | PLANS | SEQUENCES | TEMPORARY | TEMP }","verb":"DISCARD"}},"Definition":{"Collection":"sql","Key":"discard","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"discard","SourceRevision":"wiki-repair-20261023:a47272e51ee2dd74658651b66c2d7748eff75d701cb42fc82112aefd760ed857","Facts":{"anchor":"SQL-DISCARD","description_zh":"丢弃会话状态","description_zh_html":"\u003cpre\u003eDISCARD { ALL | PLANS | SEQUENCES | TEMPORARY | TEMP }\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003eDISCARD\u003c/code\u003e 释放与数据库会话关联的内部资源。该命令可用于部分或完全重置会话状态。它提供了若干子命令，用于释放不同类型的资源；\u003ccode class=\"command\"\u003eDISCARD ALL\u003c/code\u003e 变体涵盖了其他所有子命令，并且还会重置额外的状态。\n  \u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e参数\u003c/h2\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ePLANS\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      释放所有缓存的查询计划，从而在下一次使用相关预备语句时强制重新规划。\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eSEQUENCES\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      丢弃所有缓存的序列相关状态，包括\n      \u003ccode class=\"function\"\u003ecurrval()\u003c/code\u003e/\u003ccode class=\"function\"\u003elastval()\u003c/code\u003e 信息，以及所有尚未由 \u003ccode class=\"function\"\u003enextval()\u003c/code\u003e 返回的预分配序列值。（关于预分配序列值的说明，请参见 \u003ca class=\"xref\" href=\"/zh/docs/18/sql-createsequence.html\" title=\"CREATE SEQUENCE\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE SEQUENCE\u003c/span\u003e\u003c/a\u003e。）\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eTEMPORARY\u003c/code\u003e 或 \u003ccode class=\"literal\"\u003eTEMP\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      删除当前会话中创建的所有临时表。\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eALL\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      释放与当前会话相关的所有临时资源，并将会话重置为其初始状态。目前，这与执行下列语句序列的效果相同：\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e\nCLOSE ALL;\nSET SESSION AUTHORIZATION DEFAULT;\nRESET ALL;\nDEALLOCATE ALL;\nUNLISTEN *;\nSELECT pg_advisory_unlock_all();\nDISCARD PLANS;\nDISCARD TEMP;\nDISCARD SEQUENCES;\n\u003c/pre\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e注解\u003c/h2\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003eDISCARD ALL\u003c/code\u003e 不能在事务块内部执行。\n   \u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003eDISCARD\u003c/code\u003e 是 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 扩展。\n  \u003c/p\u003e\u003c/section\u003e","file":"sql-discard.html","lang":"en","name":"DISCARD","purpose":"discard session state","purpose_zh":"丢弃会话状态","related":[],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eDISCARD\u003c/code\u003e releases internal resources associated with a database session. This command is useful for partially or fully resetting the session's state. There are several subcommands to release different types of resources; the \u003ccode class=\"command\"\u003eDISCARD ALL\u003c/code\u003e variant subsumes all the others, and also resets additional state.\u003c/p\u003e","key":"description","title":"Description"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ePLANS\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eReleases all cached query plans, forcing re-planning to occur the next time the associated prepared statement is used.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eSEQUENCES\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eDiscards all cached sequence-related state, including \u003ccode class=\"function\"\u003ecurrval()\u003c/code\u003e/\u003ccode class=\"function\"\u003elastval()\u003c/code\u003e information and any preallocated sequence values that have not yet been returned by \u003ccode class=\"function\"\u003enextval()\u003c/code\u003e. (See \u003ca href=\"/docs/18/sql-createsequence.html\" title=\"CREATE SEQUENCE\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE SEQUENCE\u003c/span\u003e\u003c/a\u003e for a description of preallocated sequence values.)\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eTEMPORARY\u003c/code\u003e or \u003ccode class=\"literal\"\u003eTEMP\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eDrops all temporary tables created in the current session.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eALL\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eReleases all temporary resources associated with the current session and resets the session to its initial state. Currently, this has the same effect as executing the following sequence of statements:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCLOSE ALL;\nSET SESSION AUTHORIZATION DEFAULT;\nRESET ALL;\nDEALLOCATE ALL;\nUNLISTEN *;\nSELECT pg_advisory_unlock_all();\nDISCARD PLANS;\nDISCARD TEMP;\nDISCARD SEQUENCES;\n\u003c/pre\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eDISCARD ALL\u003c/code\u003e cannot be executed inside a transaction block.\u003c/p\u003e","key":"notes","title":"Notes"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eDISCARD\u003c/code\u003e is a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extension.\u003c/p\u003e","key":"compatibility","title":"Compatibility"}],"sections_same_as":"","slug":"18","synopsis_html":"DISCARD { ALL | PLANS | SEQUENCES | TEMPORARY | TEMP }","synopsis_text":"DISCARD { ALL | PLANS | SEQUENCES | TEMPORARY | TEMP }","translation_provenance":{"inputs":[{"kind":"current-pgdoc-translation","path":"/Users/vonng/pgsty/pgdoc/zh/18/html/sql-discard.html","sha256":"1e2d8cdef071a8c2f51c41116cd269b395167e38edd897a3159f353ffa98a438"}],"kind":"same-version-pgdoc","locale":"zh-Hans","source_revision":"b1b500221dbe5437cfca004d6b04d3f6e422765d","version":"18"},"zh_from":"same-version-pgdoc"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"discard","SourceDatabase":"center","Version":"18","Locale":"en","Title":"DISCARD","Summary":"discard session state","BodyHTML":"\u003cpre\u003eDISCARD { ALL | PLANS | SEQUENCES | TEMPORARY | TEMP }\u003c/pre\u003e\u003csection\u003e\u003ch2\u003eDescription\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eDISCARD\u003c/code\u003e releases internal resources associated with a database session. This command is useful for partially or fully resetting the session\u0026#39;s state. There are several subcommands to release different types of resources; the \u003ccode\u003eDISCARD ALL\u003c/code\u003e variant subsumes all the others, and also resets additional state.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eParameters\u003c/h2\u003e\u003cdiv\u003e\u003cdl\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003ePLANS\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eReleases all cached query plans, forcing re-planning to occur the next time the associated prepared statement is used.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003eSEQUENCES\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eDiscards all cached sequence-related state, including \u003ccode\u003ecurrval()\u003c/code\u003e/\u003ccode\u003elastval()\u003c/code\u003e information and any preallocated sequence values that have not yet been returned by \u003ccode\u003enextval()\u003c/code\u003e. (See \u003ca href=\"/docs/18/sql-createsequence.html\" title=\"CREATE SEQUENCE\" rel=\"nofollow\"\u003e\u003cspan\u003eCREATE SEQUENCE\u003c/span\u003e\u003c/a\u003e for a description of preallocated sequence values.)\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003eTEMPORARY\u003c/code\u003e or \u003ccode\u003eTEMP\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eDrops all temporary tables created in the current session.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003eALL\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eReleases all temporary resources associated with the current session and resets the session to its initial state. Currently, this has the same effect as executing the following sequence of statements:\u003c/p\u003e\u003cpre\u003eCLOSE ALL;\nSET SESSION AUTHORIZATION DEFAULT;\nRESET ALL;\nDEALLOCATE ALL;\nUNLISTEN *;\nSELECT pg_advisory_unlock_all();\nDISCARD PLANS;\nDISCARD TEMP;\nDISCARD SEQUENCES;\n\u003c/pre\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eNotes\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eDISCARD ALL\u003c/code\u003e cannot be executed inside a transaction block.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eCompatibility\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eDISCARD\u003c/code\u003e is a \u003cspan\u003ePostgreSQL\u003c/span\u003e extension.\u003c/p\u003e\u003c/section\u003e","SourceRevision":"wiki-repair-20261023:a47272e51ee2dd74658651b66c2d7748eff75d701cb42fc82112aefd760ed857","ContentHash":"257df8f294b6196b89b5c5e2f25ae5366848b556b71f8aa447d6166e0618418c","Payload":{"related":[],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eDISCARD\u003c/code\u003e releases internal resources associated with a database session. This command is useful for partially or fully resetting the session's state. There are several subcommands to release different types of resources; the \u003ccode class=\"command\"\u003eDISCARD ALL\u003c/code\u003e variant subsumes all the others, and also resets additional state.\u003c/p\u003e","key":"description","title":"Description"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ePLANS\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eReleases all cached query plans, forcing re-planning to occur the next time the associated prepared statement is used.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eSEQUENCES\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eDiscards all cached sequence-related state, including \u003ccode class=\"function\"\u003ecurrval()\u003c/code\u003e/\u003ccode class=\"function\"\u003elastval()\u003c/code\u003e information and any preallocated sequence values that have not yet been returned by \u003ccode class=\"function\"\u003enextval()\u003c/code\u003e. (See \u003ca href=\"/docs/18/sql-createsequence.html\" title=\"CREATE SEQUENCE\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE SEQUENCE\u003c/span\u003e\u003c/a\u003e for a description of preallocated sequence values.)\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eTEMPORARY\u003c/code\u003e or \u003ccode class=\"literal\"\u003eTEMP\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eDrops all temporary tables created in the current session.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eALL\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eReleases all temporary resources associated with the current session and resets the session to its initial state. Currently, this has the same effect as executing the following sequence of statements:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCLOSE ALL;\nSET SESSION AUTHORIZATION DEFAULT;\nRESET ALL;\nDEALLOCATE ALL;\nUNLISTEN *;\nSELECT pg_advisory_unlock_all();\nDISCARD PLANS;\nDISCARD TEMP;\nDISCARD SEQUENCES;\n\u003c/pre\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eDISCARD ALL\u003c/code\u003e cannot be executed inside a transaction block.\u003c/p\u003e","key":"notes","title":"Notes"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eDISCARD\u003c/code\u003e is a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extension.\u003c/p\u003e","key":"compatibility","title":"Compatibility"}],"sections_same_as":"","synopsis_html":"DISCARD { ALL | PLANS | SEQUENCES | TEMPORARY | TEMP }","synopsis_text":"DISCARD { ALL | PLANS | SEQUENCES | TEMPORARY | TEMP }"}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","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}
