{"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","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"],"slug":"unlisten","source_rev":"a709ab85","synopsis":"UNLISTEN { channel | * }","verb":"UNLISTEN"}},"Definition":{"Collection":"sql","Key":"unlisten","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"unlisten","SourceRevision":"a709ab85","Facts":{"anchor":"SQL-UNLISTEN","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 | * }"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"unlisten","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"UNLISTEN","Summary":"停止监听通知","BodyHTML":"\u003cpre\u003eUNLISTEN { channel | * }\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eUNLISTEN\u003c/code\u003e用于移除现有的 \u003ccode\u003eNOTIFY\u003c/code\u003e事件注册。\u003ccode\u003eUNLISTEN\u003c/code\u003e会取消当前 \u003cspan\u003ePostgreSQL\u003c/span\u003e会话作为名为\u003cem\u003e\u003ccode\u003echannel\u003c/code\u003e\u003c/em\u003e的通知通道监听者的任何现有注册。特殊通配符\u003ccode\u003e*\u003c/code\u003e会取消当前会话的所有监听注册。\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中对\u003ccode\u003eLISTEN\u003c/code\u003e和\u003ccode\u003eNOTIFY\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\u003echannel\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\u003e*\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对自己并未监听的通道执行\u003ccode\u003eUNLISTEN\u003c/code\u003e，不会出现警告或错误。\u003c/p\u003e\u003cp\u003e每个会话结束时，都会自动执行\u003ccode\u003eUNLISTEN *\u003c/code\u003e。\u003c/p\u003e\u003cp\u003e执行过\u003ccode\u003eUNLISTEN\u003c/code\u003e的事务不能进入两阶段提交的预备状态。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e示例\u003c/h2\u003e\u003cp\u003e建立一个监听注册：\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\u003e执行\u003ccode\u003eUNLISTEN\u003c/code\u003e之后，后续的\u003ccode\u003eNOTIFY\u003c/code\u003e 消息将被忽略：\u003c/p\u003e\u003cpre\u003eUNLISTEN virtual;\nNOTIFY virtual;\n-- no NOTIFY event is received\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003eSQL 标准中没有\u003ccode\u003eUNLISTEN\u003c/code\u003e语句。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e另见\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":"1b5ca64c","ContentHash":"e4c860faada5d6b6ca897ffb59130748e1db7bf80b9a4e50483abe0f7e4673bd","Payload":{"purpose_zh":"停止监听通知","sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e用于移除现有的 \u003ccode class=\"command\"\u003eNOTIFY\u003c/code\u003e事件注册。\u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e会取消当前 \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会取消当前会话的所有监听注册。\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中对\u003ccode class=\"command\"\u003eLISTEN\u003c/code\u003e和\u003ccode class=\"command\"\u003eNOTIFY\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\u003echannel\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\"\u003e*\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对自己并未监听的通道执行\u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e，不会出现警告或错误。\u003c/p\u003e\u003cp\u003e每个会话结束时，都会自动执行\u003ccode class=\"command\"\u003eUNLISTEN *\u003c/code\u003e。\u003c/p\u003e\u003cp\u003e执行过\u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e的事务不能进入两阶段提交的预备状态。\u003c/p\u003e","key":"notes","title":"注解"},{"html":"\u003cp\u003e建立一个监听注册：\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\u003e执行\u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e之后，后续的\u003ccode class=\"command\"\u003eNOTIFY\u003c/code\u003e 消息将被忽略：\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eUNLISTEN virtual;\nNOTIFY virtual;\n-- no NOTIFY event is received\n\u003c/pre\u003e","key":"examples","title":"示例"},{"html":"\u003cp\u003eSQL 标准中没有\u003ccode class=\"command\"\u003eUNLISTEN\u003c/code\u003e语句。\u003c/p\u003e","key":"compatibility","title":"兼容性"},{"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":"另见"}],"sections_same_as":"","synopsis_html":"UNLISTEN { \u003cem class=\"replaceable\"\u003e\u003ccode\u003echannel\u003c/code\u003e\u003c/em\u003e | * }","synopsis_text":"UNLISTEN { channel | * }"}},"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}
