PostgreSQL学习第十四篇 listen与notify

Postgresql提供了client端之间通过服务器端进行消息通信的机制。这种机制是通过listen和notify命令来完成的。

session1:
postgres=# listen postgres;
LISTEN
postgres=# listen liming
postgres-# ;
LISTEN

session2:
postgres=# notify postgres,'hello word';
NOTIFY
postgres=# notify liming,'hello liming';
NOTIFY
postgres=#

session1;
postgres=# select 1;   --随便执行了一个命令
 ?column?
----------
        1
(1 row)

Asynchronous notification "postgres" with payload "hello word" received from server process with PID 12241.
Asynchronous notification "liming" with payload "hello liming" received from server process with PID 12241.
postgres=#  

listen和notify的相关命令:

	1. listen:监听消息通道
	2. unlisten:取消先前的监听
	3. notify:发送消息到消息通道中
	4. pg_notify():与notify命令功能相同
	5. pg_listening_channels():调用函数可以查询当前session已注册了哪些消息监听

相关文章

项目需要,有个数据需要导入,拿到手一开始以为是mysql,结果...
本文小编为大家详细介绍“怎么查看PostgreSQL数据库中所有表...
错误现象问题原因这是在远程连接时pg_hba.conf文件没有配置正...
因本地资源有限,在公共测试环境搭建了PGsql环境,从数据库本...
wamp 环境 这个提示就是说你的版本低于10了。 先打印ph...
psycopg2.OperationalError: SSL SYSCALL error: EOF detect...