{"Entry":{"collection":"sql","key":"close","name":"CLOSE","aliases":["close"],"metadata":{"aliases":["close"],"changed_in":["7.4","8.3"],"changes":[{"from":"7.0","purpose_changed":false,"renamed":{"from_file":"sql-close.htm","to_file":"sql-close.html"},"sections":{"added":[],"changed":[],"removed":[]},"status":"changed","synopsis":null,"to":"7.1"},{"from":"7.1","purpose_changed":true,"renamed":null,"sections":{"added":[],"changed":["description"],"removed":[]},"status":"changed","synopsis":null,"to":"7.2"},{"from":"7.3","purpose_changed":false,"renamed":null,"sections":{"added":["parameters","notes","examples"],"changed":["description","compatibility"],"removed":["usage"]},"status":"changed","synopsis":{"added":["CLOSE name"],"removed":["CLOSE cursor"]},"to":"7.4"},{"from":"7.4","purpose_changed":false,"renamed":null,"sections":{"added":["see_also"],"changed":[],"removed":[]},"status":"changed","synopsis":null,"to":"8.0"},{"from":"8.1","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["notes"],"removed":[]},"status":"changed","synopsis":null,"to":"8.2"},{"from":"8.2","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters","compatibility"],"removed":[]},"status":"changed","synopsis":{"added":["CLOSE { name | ALL }"],"removed":[]},"to":"8.3"},{"from":"8.3","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["notes"],"removed":[]},"status":"changed","synopsis":null,"to":"8.4"}],"content_hash":"6f0264eaf80110e99f00bdb782b874682549f4697151a75a20616729c2f14e93","derived_content_hash":"563b807095193325a3b2997b3b2fde4927e79546625a721632a2a17bd082118c","editorial":{},"first_version":"6.4","group":"cursor","imported_at":"2026-09-30T17:43:39.148763+08:00","last_version":"20","name":"CLOSE","object":"","position":12000,"present_in":["6.4","6.5","7.0","7.1","7.2","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":"close a cursor","purpose_zh":"","related":["declare","fetch","move"],"repair_provenance":{"original_source_revision":"wiki-repair-20261023:b01489f83684dd2c7cc632501725028821be0ac9ac063dffa23fd8e2017f8bec","receipt_sha256":"c7f7f7909b077ba0461bbd6437a288b1e34d145b4f5593cffea40d6897d93cf7","repair":"wiki-repair-20261023"},"slug":"close","source_rev":"wiki-repair-20261023:1f9e42727c93aea298044aead9b907635176b9bb6e836894465aadffa79bb75d","synopsis":"CLOSE { name | ALL }","verb":"CLOSE"}},"Definition":{"Collection":"sql","Key":"close","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"close","SourceRevision":"wiki-repair-20261023:1f9e42727c93aea298044aead9b907635176b9bb6e836894465aadffa79bb75d","Facts":{"anchor":"SQL-CLOSE","description_zh":"关闭一个游标","description_zh_html":"\u003cpre\u003eCLOSE { name | ALL }\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003eCLOSE\u003c/code\u003e 释放与一个打开的游标相关联的资源。游标关闭后，不允许再对其执行任何后续操作。当不再需要游标时，应将其关闭。\n  \u003c/p\u003e\u003cp\u003e\n   每个不可保持的打开游标都会在事务通过 \u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e 或\n   \u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e 结束时被隐式关闭。可保持游标会在创建它的事务通过 \u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e 中止时被隐式关闭。如果创建它的事务成功提交，则该可保持游标会一直保持打开状态，直到显式执行\n   \u003ccode class=\"command\"\u003eCLOSE\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\u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\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\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e注解\u003c/h2\u003e\u003cp\u003e\n\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 没有显式的 \u003ccode class=\"command\"\u003eOPEN\u003c/code\u003e 游标语句；游标在声明时即被视为打开。请使用 \u003ca class=\"link\" href=\"/zh/docs/18/sql-declare.html\" title=\"DECLARE\"\u003e\u003ccode class=\"command\"\u003eDECLARE\u003c/code\u003e\u003c/a\u003e 语句来声明游标。\n  \u003c/p\u003e\u003cp\u003e\n   可以通过查询 \u003ca class=\"link\" href=\"/zh/docs/18/view-pg-cursors.html\" title=\"53.7. pg_cursors\"\u003e\u003ccode class=\"structname\"\u003epg_cursors\u003c/code\u003e\u003c/a\u003e\n   系统视图查看所有可用游标。\n  \u003c/p\u003e\u003cp\u003e\n   如果在某个保存点之后关闭了游标，而该保存点后来又被回滚，则 \u003ccode class=\"command\"\u003eCLOSE\u003c/code\u003e 不会被回滚；也就是说，该游标仍然保持关闭状态。\n  \u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e示例\u003c/h2\u003e\u003cp\u003e\n   关闭游标 \u003ccode class=\"literal\"\u003eliahona\u003c/code\u003e：\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e\nCLOSE liahona;\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003eCLOSE\u003c/code\u003e 完全符合 SQL 标准。\u003ccode class=\"command\"\u003eCLOSE ALL\u003c/code\u003e 是 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 的一种扩展。\n  \u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e另见\u003c/h2\u003e\u003cspan class=\"simplelist\"\u003e\u003ca class=\"xref\" href=\"/zh/docs/18/sql-declare.html\" title=\"DECLARE\"\u003e\u003cspan class=\"refentrytitle\"\u003eDECLARE\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/zh/docs/18/sql-fetch.html\" title=\"FETCH\"\u003e\u003cspan class=\"refentrytitle\"\u003eFETCH\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/zh/docs/18/sql-move.html\" title=\"MOVE\"\u003e\u003cspan class=\"refentrytitle\"\u003eMOVE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","file":"sql-close.html","lang":"en","name":"CLOSE","purpose":"close a cursor","purpose_zh":"关闭一个游标","related":["declare","fetch","move"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCLOSE\u003c/code\u003e frees the resources associated with an open cursor. After the cursor is closed, no subsequent operations are allowed on it. A cursor should be closed when it is no longer needed.\u003c/p\u003e\u003cp\u003eEvery non-holdable open cursor is implicitly closed when a transaction is terminated by \u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e or \u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e. A holdable cursor is implicitly closed if the transaction that created it aborts via \u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e. If the creating transaction successfully commits, the holdable cursor remains open until an explicit \u003ccode class=\"command\"\u003eCLOSE\u003c/code\u003e is executed, or the client disconnects.\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 an open cursor to close.\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\u003eClose all open cursors.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003e\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e does not have an explicit \u003ccode class=\"command\"\u003eOPEN\u003c/code\u003e cursor statement; a cursor is considered open when it is declared. Use the \u003ca href=\"/docs/18/sql-declare.html\" title=\"DECLARE\"\u003e\u003ccode class=\"command\"\u003eDECLARE\u003c/code\u003e\u003c/a\u003e statement to declare a cursor.\u003c/p\u003e\u003cp\u003eYou can see all available cursors by querying the \u003ca href=\"/docs/18/view-pg-cursors.html\" title=\"53.7. pg_cursors\"\u003e\u003ccode class=\"structname\"\u003epg_cursors\u003c/code\u003e\u003c/a\u003e system view.\u003c/p\u003e\u003cp\u003eIf a cursor is closed after a savepoint which is later rolled back, the \u003ccode class=\"command\"\u003eCLOSE\u003c/code\u003e is not rolled back; that is, the cursor remains closed.\u003c/p\u003e","key":"notes","title":"Notes"},{"html":"\u003cp\u003eClose the cursor \u003ccode class=\"literal\"\u003eliahona\u003c/code\u003e:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCLOSE liahona;\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCLOSE\u003c/code\u003e is fully conforming with the SQL standard. \u003ccode class=\"command\"\u003eCLOSE ALL\u003c/code\u003e is a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extension.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/declare/?v=18\" title=\"DECLARE\"\u003e\u003cspan class=\"refentrytitle\"\u003eDECLARE\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/fetch/?v=18\" title=\"FETCH\"\u003e\u003cspan class=\"refentrytitle\"\u003eFETCH\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/move/?v=18\" title=\"MOVE\"\u003e\u003cspan class=\"refentrytitle\"\u003eMOVE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","slug":"18","synopsis_html":"CLOSE { \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e | ALL }","synopsis_text":"CLOSE { name | ALL }","translation_provenance":{"inputs":[{"kind":"current-pgdoc-translation","path":"/Users/vonng/pgsty/pgdoc/zh/18/html/sql-close.html","sha256":"972cc18771fe9ce79ccc558c0c8b846fe212dd3c9b550a70393f9c4880b3528c"}],"kind":"same-version-pgdoc","locale":"zh-Hans","source_revision":"b1b500221dbe5437cfca004d6b04d3f6e422765d","version":"18"},"zh_from":"same-version-pgdoc"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"close","SourceDatabase":"center","Version":"18","Locale":"en","Title":"CLOSE","Summary":"close a cursor","BodyHTML":"\u003cpre\u003eCLOSE { name | ALL }\u003c/pre\u003e\u003csection\u003e\u003ch2\u003eDescription\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eCLOSE\u003c/code\u003e frees the resources associated with an open cursor. After the cursor is closed, no subsequent operations are allowed on it. A cursor should be closed when it is no longer needed.\u003c/p\u003e\u003cp\u003eEvery non-holdable open cursor is implicitly closed when a transaction is terminated by \u003ccode\u003eCOMMIT\u003c/code\u003e or \u003ccode\u003eROLLBACK\u003c/code\u003e. A holdable cursor is implicitly closed if the transaction that created it aborts via \u003ccode\u003eROLLBACK\u003c/code\u003e. If the creating transaction successfully commits, the holdable cursor remains open until an explicit \u003ccode\u003eCLOSE\u003c/code\u003e is executed, or the client disconnects.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eParameters\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\u003eThe name of an open cursor to close.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003eALL\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eClose all open cursors.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eNotes\u003c/h2\u003e\u003cp\u003e\u003cspan\u003ePostgreSQL\u003c/span\u003e does not have an explicit \u003ccode\u003eOPEN\u003c/code\u003e cursor statement; a cursor is considered open when it is declared. Use the \u003ca href=\"/docs/18/sql-declare.html\" title=\"DECLARE\" rel=\"nofollow\"\u003e\u003ccode\u003eDECLARE\u003c/code\u003e\u003c/a\u003e statement to declare a cursor.\u003c/p\u003e\u003cp\u003eYou can see all available cursors by querying the \u003ca href=\"/docs/18/view-pg-cursors.html\" rel=\"nofollow\"\u003e\u003ccode\u003epg_cursors\u003c/code\u003e\u003c/a\u003e system view.\u003c/p\u003e\u003cp\u003eIf a cursor is closed after a savepoint which is later rolled back, the \u003ccode\u003eCLOSE\u003c/code\u003e is not rolled back; that is, the cursor remains closed.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eExamples\u003c/h2\u003e\u003cp\u003eClose the cursor \u003ccode\u003eliahona\u003c/code\u003e:\u003c/p\u003e\u003cpre\u003eCLOSE liahona;\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eCompatibility\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eCLOSE\u003c/code\u003e is fully conforming with the SQL standard. \u003ccode\u003eCLOSE ALL\u003c/code\u003e is a \u003cspan\u003ePostgreSQL\u003c/span\u003e extension.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/wiki/sql/declare/?v=18\" title=\"DECLARE\" rel=\"nofollow\"\u003e\u003cspan\u003eDECLARE\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/fetch/?v=18\" title=\"FETCH\" rel=\"nofollow\"\u003e\u003cspan\u003eFETCH\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/move/?v=18\" title=\"MOVE\" rel=\"nofollow\"\u003e\u003cspan\u003eMOVE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","SourceRevision":"wiki-repair-20261023:1f9e42727c93aea298044aead9b907635176b9bb6e836894465aadffa79bb75d","ContentHash":"fa12cb24d56c7c0ccad16f324a229afc4ffc6639445c2453095dc56447d2a8c0","Payload":{"related":["declare","fetch","move"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCLOSE\u003c/code\u003e frees the resources associated with an open cursor. After the cursor is closed, no subsequent operations are allowed on it. A cursor should be closed when it is no longer needed.\u003c/p\u003e\u003cp\u003eEvery non-holdable open cursor is implicitly closed when a transaction is terminated by \u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e or \u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e. A holdable cursor is implicitly closed if the transaction that created it aborts via \u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e. If the creating transaction successfully commits, the holdable cursor remains open until an explicit \u003ccode class=\"command\"\u003eCLOSE\u003c/code\u003e is executed, or the client disconnects.\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 an open cursor to close.\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\u003eClose all open cursors.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003e\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e does not have an explicit \u003ccode class=\"command\"\u003eOPEN\u003c/code\u003e cursor statement; a cursor is considered open when it is declared. Use the \u003ca href=\"/docs/18/sql-declare.html\" title=\"DECLARE\"\u003e\u003ccode class=\"command\"\u003eDECLARE\u003c/code\u003e\u003c/a\u003e statement to declare a cursor.\u003c/p\u003e\u003cp\u003eYou can see all available cursors by querying the \u003ca href=\"/docs/18/view-pg-cursors.html\" title=\"53.7. pg_cursors\"\u003e\u003ccode class=\"structname\"\u003epg_cursors\u003c/code\u003e\u003c/a\u003e system view.\u003c/p\u003e\u003cp\u003eIf a cursor is closed after a savepoint which is later rolled back, the \u003ccode class=\"command\"\u003eCLOSE\u003c/code\u003e is not rolled back; that is, the cursor remains closed.\u003c/p\u003e","key":"notes","title":"Notes"},{"html":"\u003cp\u003eClose the cursor \u003ccode class=\"literal\"\u003eliahona\u003c/code\u003e:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCLOSE liahona;\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCLOSE\u003c/code\u003e is fully conforming with the SQL standard. \u003ccode class=\"command\"\u003eCLOSE ALL\u003c/code\u003e is a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extension.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/declare/?v=18\" title=\"DECLARE\"\u003e\u003cspan class=\"refentrytitle\"\u003eDECLARE\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/fetch/?v=18\" title=\"FETCH\"\u003e\u003cspan class=\"refentrytitle\"\u003eFETCH\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/move/?v=18\" title=\"MOVE\"\u003e\u003cspan class=\"refentrytitle\"\u003eMOVE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","synopsis_html":"CLOSE { \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e | ALL }","synopsis_text":"CLOSE { name | ALL }"}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","6.4","6.5","7.0","7.1","7.2","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}
