\watch
重复执行当前查询缓冲区(如同 \g 一样),直到被中断、查询失败、达到执行次数上限(如果给定)或查询返回的行数低于最小要求。两次执行之间等待指定的秒数(默认 2 秒)。默认等待时间可通过变量 WATCH_INTERVAL 修改。为保持向后兼容, seconds 可以带或不带 interval= 前缀。每次查询结果都会带有一个头部,其中包含 \pset title 字符串(如果有)、查询开始时的时间以及延迟间隔。
当前查看 PostgreSQL 18.6。
说明
重复执行当前查询缓冲区(如同 \g 一样),直到被中断、查询失败、达到执行次数上限(如果给定)或查询返回的行数低于最小要求。两次执行之间等待指定的秒数(默认 2 秒)。默认等待时间可通过变量 WATCH_INTERVAL 修改。为保持向后兼容, seconds 可以带或不带 interval= 前缀。每次查询结果都会带有一个头部,其中包含 \pset title 字符串(如果有)、查询开始时的时间以及延迟间隔。
- 客户端
- psql 18.6
- 区分大小写的写法
- \watch
用法
\watch [ i[nterval]= seconds ] [ c[ount]= times ] [ m[in_rows]= rows ] [ seconds ]本版手册中的写法
| 命令 | 手册中的后缀修饰符 |
|---|---|
| \watch | 此语法签名未列出 |
手册定义
\watch [ i[nterval]=seconds] [ c[ount]=times] [ m[in_rows]=rows] [seconds]-
重复执行当前查询缓冲区(如同
\g一样),直到被中断、查询失败、达到执行次数上限(如果给定)或查询返回的行数低于最小要求。两次执行之间等待指定的秒数(默认 2 秒)。默认等待时间可通过变量WATCH_INTERVAL修改。为保持向后兼容,seconds可以带或不带interval=前缀。每次查询结果都会带有一个头部,其中包含\pset title字符串(如果有)、查询开始时的时间以及延迟间隔。若当前查询缓冲区为空,则重新执行最近发送的查询。
相关条目
文档与源码
来源构建
- 版本
- 18.6
- 构建
- https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2
- 来源指纹
ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8
版本比较
PostgreSQL 17 → 18: 属性变化。
以下差异保留原始字段名与英文源描述。
--- PostgreSQL 17
+++ PostgreSQL 18
@@ -1,5 +1,5 @@
{
- "definition": "Repeatedly execute the current query buffer (as \\g does) until interrupted, or the query fails, or the execution count limit (if given) is reached, or the query no longer returns the minimum number of rows. Wait the specified number of seconds (default 2) between executions. For backwards compatibility, seconds can be specified with or without an interval= prefix. Each query result is displayed with a header that includes the \\pset title string (if any), the time as of query start, and the delay interval. If the current query buffer is empty, the most recently sent query is re-executed instead.",
+ "definition": "Repeatedly execute the current query buffer (as \\g does) until interrupted, or the query fails, or the execution count limit (if given) is reached, or the query no longer returns the minimum number of rows. Wait the specified number of seconds (default 2) between executions. The default wait can be changed with the variable WATCH_INTERVAL . For backwards compatibility, seconds can be specified with or without an interval= prefix. Each query result is displayed with a header that includes the \\pset title string (if any), the time as of query start, and the delay interval. If the current query buffer is empty, the most recently sent query is re-executed instead.",
"modifiers": [],
"signature": "\\watch [ i[nterval]= seconds ] [ c[ount]= times ] [ m[in_rows]= rows ] [ seconds ]",
"spellings": [
比较已记录的接口与属性,排除来源指纹和构建元数据。某个样本中没有记录,不能据此判断实际引入或移除的版本。
相关条目
导出 JSON · 返回psql 命令 · 收录范围为 PostgreSQL 10 至 20;最早采样版本不一定是实际引入版本。