UNLISTEN

一个停止监听通知的SQL命令

UNLISTEN 是一个用于取消特定或所有事件通知注册的实用命令。

UNLISTEN 命令是在 PostgreSQL 6.4 中添加的。

用法

如果客户端在此会话中先前执行了 LISTEN channel 命令,那么 UNLISTEN 将会使客户端停止监听该频道上的通知。或者,UNLISTEN * 将会使客户端停止监听所有频道上的通知。

变更历史

示例

UNLISTEN 的使用示例

postgres=# LISTEN somechannel;
LISTEN

postgres=# LISTEN otherchannel;
LISTEN

postgres=# LISTEN foo;
LISTEN

postgres=# SELECT * FROM pg_listening_channels();
 pg_listening_channels 
-----------------------
 somechannel
 otherchannel
 foo
(3 rows)

postgres=# UNLISTEN foo;
UNLISTEN

postgres=# SELECT * FROM pg_listening_channels();
 pg_listening_channels 
-----------------------
 somechannel
 otherchannel
(2 rows)

postgres=# UNLISTEN *;
UNLISTEN

postgres=# SELECT * FROM pg_listening_channels();
 pg_listening_channels 
-----------------------
(0 rows)

分类

异步通知, 实用命令

另请参阅

LISTEN, NOTIFY, pg_listening_channels()

反馈

对于“UNLISTEN”提交任何评论、建议或更正,请在此处 提交