{"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","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"],"slug":"close","source_rev":"a709ab85","synopsis":"CLOSE { name | ALL }","verb":"CLOSE"}},"Definition":{"Collection":"sql","Key":"close","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"close","SourceRevision":"a709ab85","Facts":{"anchor":"SQL-CLOSE","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 }"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"close","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"CLOSE","Summary":"关闭一个游标","BodyHTML":"\u003cpre\u003eCLOSE { name | ALL }\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eCLOSE\u003c/code\u003e释放与一个打开的游标相关联的资源。游标关闭后，不允许再对其执行任何后续操作。当不再需要游标时，应将其关闭。\u003c/p\u003e\u003cp\u003e每个不可保持的打开游标都会在事务通过\u003ccode\u003eCOMMIT\u003c/code\u003e或 \u003ccode\u003eROLLBACK\u003c/code\u003e结束时被隐式关闭。可保持游标会在创建它的事务通过\u003ccode\u003eROLLBACK\u003c/code\u003e中止时被隐式关闭。如果创建它的事务成功提交，则该可保持游标会一直保持打开状态，直到显式执行 \u003ccode\u003eCLOSE\u003c/code\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\u003ccode\u003eALL\u003c/code\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\u003cspan\u003ePostgreSQL\u003c/span\u003e没有显式的\u003ccode\u003eOPEN\u003c/code\u003e游标语句；游标在声明时即被视为打开。请使用\u003ca href=\"/docs/18/sql-declare.html\" title=\"DECLARE\" rel=\"nofollow\"\u003e\u003ccode\u003eDECLARE\u003c/code\u003e\u003c/a\u003e语句来声明游标。\u003c/p\u003e\u003cp\u003e可以通过查询\u003ca href=\"/docs/18/view-pg-cursors.html\" rel=\"nofollow\"\u003e\u003ccode\u003epg_cursors\u003c/code\u003e\u003c/a\u003e 系统视图查看所有可用游标。\u003c/p\u003e\u003cp\u003e如果在某个保存点之后关闭了游标，而该保存点后来又被回滚，则\u003ccode\u003eCLOSE\u003c/code\u003e不会被回滚；也就是说，该游标仍然保持关闭状态。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e示例\u003c/h2\u003e\u003cp\u003e关闭游标\u003ccode\u003eliahona\u003c/code\u003e：\u003c/p\u003e\u003cpre\u003eCLOSE liahona;\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eCLOSE\u003c/code\u003e完全符合 SQL 标准。\u003ccode\u003eCLOSE ALL\u003c/code\u003e是\u003cspan\u003ePostgreSQL\u003c/span\u003e的一种扩展。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e另见\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":"1b5ca64c","ContentHash":"b2f56e11f70a32307cd018e14aea9baa4fe98197cb761ce9afe2988558818a6f","Payload":{"purpose_zh":"关闭一个游标","sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCLOSE\u003c/code\u003e释放与一个打开的游标相关联的资源。游标关闭后，不允许再对其执行任何后续操作。当不再需要游标时，应将其关闭。\u003c/p\u003e\u003cp\u003e每个不可保持的打开游标都会在事务通过\u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e或 \u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e结束时被隐式关闭。可保持游标会在创建它的事务通过\u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e中止时被隐式关闭。如果创建它的事务成功提交，则该可保持游标会一直保持打开状态，直到显式执行 \u003ccode class=\"command\"\u003eCLOSE\u003c/code\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\u003ccode class=\"literal\"\u003eALL\u003c/code\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\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e没有显式的\u003ccode class=\"command\"\u003eOPEN\u003c/code\u003e游标语句；游标在声明时即被视为打开。请使用\u003ca href=\"/docs/18/sql-declare.html\" title=\"DECLARE\"\u003e\u003ccode class=\"command\"\u003eDECLARE\u003c/code\u003e\u003c/a\u003e语句来声明游标。\u003c/p\u003e\u003cp\u003e可以通过查询\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 系统视图查看所有可用游标。\u003c/p\u003e\u003cp\u003e如果在某个保存点之后关闭了游标，而该保存点后来又被回滚，则\u003ccode class=\"command\"\u003eCLOSE\u003c/code\u003e不会被回滚；也就是说，该游标仍然保持关闭状态。\u003c/p\u003e","key":"notes","title":"注解"},{"html":"\u003cp\u003e关闭游标\u003ccode class=\"literal\"\u003eliahona\u003c/code\u003e：\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCLOSE liahona;\n\u003c/pre\u003e","key":"examples","title":"示例"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCLOSE\u003c/code\u003e完全符合 SQL 标准。\u003ccode class=\"command\"\u003eCLOSE ALL\u003c/code\u003e是\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e的一种扩展。\u003c/p\u003e","key":"compatibility","title":"兼容性"},{"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":"另见"}],"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":"zh-Hans","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}
