UNLISTEN
是一个用于取消特定或所有事件通知注册的实用命令。
UNLISTEN
命令是在 PostgreSQL 6.4 中添加的。
用法
如果客户端在此会话中先前执行了 LISTEN
命令,那么 channel
UNLISTEN
将会使客户端停止监听该频道上的通知。或者,UNLISTEN
将会使客户端停止监听所有频道上的通知。*
变更历史
- PostgreSQL 6.4
- 添加于 (提交 f62d1253)
示例
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)
参考资料
- PostgreSQL 文档: UNLISTEN