{"Entry":{"collection":"sql","key":"unlisten","name":"UNLISTEN","aliases":["unlisten"],"metadata":{"aliases":["unlisten"],"changed_in":["7.4","9.0"],"changes":[{"from":"6.5","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["usage"],"removed":[]},"status":"changed","synopsis":null,"to":"7.0"},{"from":"7.0","purpose_changed":false,"renamed":{"from_file":"sql-unlisten.htm","to_file":"sql-unlisten.html"},"sections":{"added":[],"changed":["description","usage"],"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.2","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description"],"removed":[]},"status":"changed","synopsis":null,"to":"7.3"},{"from":"7.3","purpose_changed":false,"renamed":null,"sections":{"added":["parameters","notes","examples","see_also"],"changed":["description","compatibility"],"removed":["usage"]},"status":"changed","synopsis":{"added":["UNLISTEN { name | * }"],"removed":["UNLISTEN { notifyname | * }"]},"to":"7.4"},{"from":"8.2","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["notes"],"removed":[]},"status":"changed","synopsis":null,"to":"8.3"},{"from":"8.4","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description","parameters","notes","examples"],"removed":[]},"status":"changed","synopsis":{"added":["UNLISTEN { channel | * }"],"removed":["UNLISTEN { name | * }"]},"to":"9.0"}],"content_hash":"95500d620fcffade967367ee3cccbc057b465ce229039786eb698670c71b8790","derived_content_hash":"89bf3f8a7ee7116895c50d75f6b7b2e85c404080576b3da8e297bfb22c0943f3","editorial":{},"first_version":"6.4","group":"session","imported_at":"2026-09-30T17:43:39.541147+08:00","last_version":"20","name":"UNLISTEN","object":"","position":14006,"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":"stop listening for a notification","purpose_zh":"","related":["listen","notify"],"repair_provenance":{"original_source_revision":"wiki-repair-20261023:831eba30bcb0d858b21a2454f5e948c1928a24e18b0baaedc417436c9798e680","receipt_sha256":"0795c50b3d49ed9fac9f360dc3eb05fac3f3e4e77b94a2d8efd9e036361cbc78","repair":"wiki-repair-20261023"},"slug":"unlisten","source_rev":"wiki-repair-20261023:243203e2799d289d8e247ac170a5e2e58092eb98bb5b683b755a3f4d183d94e5","synopsis":"UNLISTEN { channel | * }","verb":"UNLISTEN"}},"Definition":{"Collection":"sql","Key":"unlisten","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"unlisten","SourceRevision":"wiki-repair-20261023:243203e2799d289d8e247ac170a5e2e58092eb98bb5b683b755a3f4d183d94e5","Facts":{"anchor":"SQL-UNLISTEN","description_zh":"停止监听通知","description_zh_html":"\u003cpre\u003eUNLISTEN { channel | * }\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e 用于移除现有的\n   \u003ccode class=\"command\"\u003eNOTIFY\u003c/code\u003e 事件注册。\u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e 会取消当前\n   \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 会话作为名为 \u003cem class=\"replaceable\"\u003e\u003ccode\u003echannel\u003c/code\u003e\u003c/em\u003e 的通知通道监听者的任何现有注册。特殊通配符\u003ccode class=\"literal\"\u003e*\u003c/code\u003e 会取消当前会话的所有监听注册。\n  \u003c/p\u003e\u003cp\u003e\n\u003ca class=\"xref\" href=\"/zh/docs/18/sql-notify.html\" title=\"NOTIFY\"\u003e\u003cspan class=\"refentrytitle\"\u003eNOTIFY\u003c/span\u003e\u003c/a\u003e 中对 \u003ccode class=\"command\"\u003eLISTEN\u003c/code\u003e 和 \u003ccode class=\"command\"\u003eNOTIFY\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\u003echannel\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\"\u003e*\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   对自己并未监听的通道执行 \u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e，不会出现警告或错误。\n  \u003c/p\u003e\u003cp\u003e\n   每个会话结束时，都会自动执行 \u003ccode class=\"command\"\u003eUNLISTEN *\u003c/code\u003e。\n  \u003c/p\u003e\u003cp\u003e\n   执行过 \u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e 的事务不能进入两阶段提交的预备状态。\n  \u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e示例\u003c/h2\u003e\u003cp\u003e\n   建立一个监听注册：\n\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e\nLISTEN virtual;\nNOTIFY virtual;\nAsynchronous notification \"virtual\" received from server process with PID 8448.\n\u003c/pre\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n   执行 \u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e 之后，后续的 \u003ccode class=\"command\"\u003eNOTIFY\u003c/code\u003e\n   消息将被忽略：\n\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e\nUNLISTEN virtual;\nNOTIFY virtual;\n-- no NOTIFY event is received\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e\n   SQL 标准中没有 \u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\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-listen.html\" title=\"LISTEN\"\u003e\u003cspan class=\"refentrytitle\"\u003eLISTEN\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/zh/docs/18/sql-notify.html\" title=\"NOTIFY\"\u003e\u003cspan class=\"refentrytitle\"\u003eNOTIFY\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","file":"sql-unlisten.html","lang":"en","name":"UNLISTEN","purpose":"stop listening for a notification","purpose_zh":"停止监听通知","related":["listen","notify"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e is used to remove an existing registration for \u003ccode class=\"command\"\u003eNOTIFY\u003c/code\u003e events. \u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e cancels any existing registration of the current \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e session as a listener on the notification channel named \u003cem class=\"replaceable\"\u003e\u003ccode\u003echannel\u003c/code\u003e\u003c/em\u003e. The special wildcard \u003ccode class=\"literal\"\u003e*\u003c/code\u003e cancels all listener registrations for the current session.\u003c/p\u003e\u003cp\u003e\u003ca href=\"/docs/18/sql-notify.html\" title=\"NOTIFY\"\u003e\u003cspan class=\"refentrytitle\"\u003eNOTIFY\u003c/span\u003e\u003c/a\u003e contains a more extensive discussion of the use of \u003ccode class=\"command\"\u003eLISTEN\u003c/code\u003e and \u003ccode class=\"command\"\u003eNOTIFY\u003c/code\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\u003echannel\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eName of a notification channel (any identifier).\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e*\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eAll current listen registrations for this session are cleared.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003eYou can unlisten something you were not listening for; no warning or error will appear.\u003c/p\u003e\u003cp\u003eAt the end of each session, \u003ccode class=\"command\"\u003eUNLISTEN *\u003c/code\u003e is automatically executed.\u003c/p\u003e\u003cp\u003eA transaction that has executed \u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e cannot be prepared for two-phase commit.\u003c/p\u003e","key":"notes","title":"Notes"},{"html":"\u003cp\u003eTo make a registration:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eLISTEN virtual;\nNOTIFY virtual;\nAsynchronous notification \"virtual\" received from server process with PID 8448.\n\u003c/pre\u003e\u003cp\u003eOnce \u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e has been executed, further \u003ccode class=\"command\"\u003eNOTIFY\u003c/code\u003e messages will be ignored:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eUNLISTEN virtual;\nNOTIFY virtual;\n-- no NOTIFY event is received\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003eThere is no \u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e command in the SQL standard.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/listen/?v=18\" title=\"LISTEN\"\u003e\u003cspan class=\"refentrytitle\"\u003eLISTEN\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/notify/?v=18\" title=\"NOTIFY\"\u003e\u003cspan class=\"refentrytitle\"\u003eNOTIFY\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","slug":"18","synopsis_html":"UNLISTEN { \u003cem class=\"replaceable\"\u003e\u003ccode\u003echannel\u003c/code\u003e\u003c/em\u003e | * }","synopsis_text":"UNLISTEN { channel | * }","translation_provenance":{"inputs":[{"kind":"current-pgdoc-translation","path":"/Users/vonng/pgsty/pgdoc/zh/18/html/sql-unlisten.html","sha256":"d0059725f029a0199b1d45542b665622ae135432da88956f7a17876dd5307f1b"}],"kind":"same-version-pgdoc","locale":"zh-Hans","source_revision":"b1b500221dbe5437cfca004d6b04d3f6e422765d","version":"18"},"zh_from":"same-version-pgdoc"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"unlisten","SourceDatabase":"center","Version":"18","Locale":"en","Title":"UNLISTEN","Summary":"stop listening for a notification","BodyHTML":"\u003cpre\u003eUNLISTEN { channel | * }\u003c/pre\u003e\u003csection\u003e\u003ch2\u003eDescription\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eUNLISTEN\u003c/code\u003e is used to remove an existing registration for \u003ccode\u003eNOTIFY\u003c/code\u003e events. \u003ccode\u003eUNLISTEN\u003c/code\u003e cancels any existing registration of the current \u003cspan\u003ePostgreSQL\u003c/span\u003e session as a listener on the notification channel named \u003cem\u003e\u003ccode\u003echannel\u003c/code\u003e\u003c/em\u003e. The special wildcard \u003ccode\u003e*\u003c/code\u003e cancels all listener registrations for the current session.\u003c/p\u003e\u003cp\u003e\u003ca href=\"/docs/18/sql-notify.html\" title=\"NOTIFY\" rel=\"nofollow\"\u003e\u003cspan\u003eNOTIFY\u003c/span\u003e\u003c/a\u003e contains a more extensive discussion of the use of \u003ccode\u003eLISTEN\u003c/code\u003e and \u003ccode\u003eNOTIFY\u003c/code\u003e.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eParameters\u003c/h2\u003e\u003cdiv\u003e\u003cdl\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003echannel\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eName of a notification channel (any identifier).\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e*\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eAll current listen registrations for this session are cleared.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eNotes\u003c/h2\u003e\u003cp\u003eYou can unlisten something you were not listening for; no warning or error will appear.\u003c/p\u003e\u003cp\u003eAt the end of each session, \u003ccode\u003eUNLISTEN *\u003c/code\u003e is automatically executed.\u003c/p\u003e\u003cp\u003eA transaction that has executed \u003ccode\u003eUNLISTEN\u003c/code\u003e cannot be prepared for two-phase commit.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eExamples\u003c/h2\u003e\u003cp\u003eTo make a registration:\u003c/p\u003e\u003cpre\u003eLISTEN virtual;\nNOTIFY virtual;\nAsynchronous notification \u0026#34;virtual\u0026#34; received from server process with PID 8448.\n\u003c/pre\u003e\u003cp\u003eOnce \u003ccode\u003eUNLISTEN\u003c/code\u003e has been executed, further \u003ccode\u003eNOTIFY\u003c/code\u003e messages will be ignored:\u003c/p\u003e\u003cpre\u003eUNLISTEN virtual;\nNOTIFY virtual;\n-- no NOTIFY event is received\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eCompatibility\u003c/h2\u003e\u003cp\u003eThere is no \u003ccode\u003eUNLISTEN\u003c/code\u003e command in the SQL standard.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/wiki/sql/listen/?v=18\" title=\"LISTEN\" rel=\"nofollow\"\u003e\u003cspan\u003eLISTEN\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/notify/?v=18\" title=\"NOTIFY\" rel=\"nofollow\"\u003e\u003cspan\u003eNOTIFY\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","SourceRevision":"wiki-repair-20261023:243203e2799d289d8e247ac170a5e2e58092eb98bb5b683b755a3f4d183d94e5","ContentHash":"c54bf0965e1aa3439120a5cc38df78393091666a5d9e4e25533b3890938e5018","Payload":{"related":["listen","notify"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e is used to remove an existing registration for \u003ccode class=\"command\"\u003eNOTIFY\u003c/code\u003e events. \u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e cancels any existing registration of the current \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e session as a listener on the notification channel named \u003cem class=\"replaceable\"\u003e\u003ccode\u003echannel\u003c/code\u003e\u003c/em\u003e. The special wildcard \u003ccode class=\"literal\"\u003e*\u003c/code\u003e cancels all listener registrations for the current session.\u003c/p\u003e\u003cp\u003e\u003ca href=\"/docs/18/sql-notify.html\" title=\"NOTIFY\"\u003e\u003cspan class=\"refentrytitle\"\u003eNOTIFY\u003c/span\u003e\u003c/a\u003e contains a more extensive discussion of the use of \u003ccode class=\"command\"\u003eLISTEN\u003c/code\u003e and \u003ccode class=\"command\"\u003eNOTIFY\u003c/code\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\u003echannel\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eName of a notification channel (any identifier).\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e*\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eAll current listen registrations for this session are cleared.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003eYou can unlisten something you were not listening for; no warning or error will appear.\u003c/p\u003e\u003cp\u003eAt the end of each session, \u003ccode class=\"command\"\u003eUNLISTEN *\u003c/code\u003e is automatically executed.\u003c/p\u003e\u003cp\u003eA transaction that has executed \u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e cannot be prepared for two-phase commit.\u003c/p\u003e","key":"notes","title":"Notes"},{"html":"\u003cp\u003eTo make a registration:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eLISTEN virtual;\nNOTIFY virtual;\nAsynchronous notification \"virtual\" received from server process with PID 8448.\n\u003c/pre\u003e\u003cp\u003eOnce \u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e has been executed, further \u003ccode class=\"command\"\u003eNOTIFY\u003c/code\u003e messages will be ignored:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eUNLISTEN virtual;\nNOTIFY virtual;\n-- no NOTIFY event is received\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003eThere is no \u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e command in the SQL standard.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/listen/?v=18\" title=\"LISTEN\"\u003e\u003cspan class=\"refentrytitle\"\u003eLISTEN\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/notify/?v=18\" title=\"NOTIFY\"\u003e\u003cspan class=\"refentrytitle\"\u003eNOTIFY\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","synopsis_html":"UNLISTEN { \u003cem class=\"replaceable\"\u003e\u003ccode\u003echannel\u003c/code\u003e\u003c/em\u003e | * }","synopsis_text":"UNLISTEN { channel | * }"}},"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}
