\bind
为下一次查询执行设置查询参数,并将指定参数传给任意参数占位符( $1 等)。
当前查看 PostgreSQL 18.6。
说明
为下一次查询执行设置查询参数,并将指定参数传给任意参数占位符( $1 等)。
- 客户端
- psql 18.6
- 区分大小写的写法
- \bind
用法
\bind [ parameter ] ...本版手册中的写法
| 命令 | 手册中的后缀修饰符 |
|---|---|
| \bind | 此语法签名未列出 |
手册定义
\bind[parameter] ...-
为下一次查询执行设置查询参数,并将指定参数传给任意参数占位符(
$1等)。示例:
INSERT INTO tbl1 VALUES ($1, $2) \bind 'first value' 'second value' \g
这对除
\g之外的查询执行命令也有效,例如\gx和\gset。此命令会使用扩展查询协议(参见第 54.1.2 节),不同于psql通常使用的简单查询协议。因此,可以用它在psql中测试扩展查询协议。(即使查询没有参数,而且此命令指定了零个参数,也会使用扩展查询协议。)此命令只影响下一条被执行的查询;之后的所有查询默认仍会使用简单查询协议。
相关条目
文档与源码
来源构建
- 版本
- 18.6
- 构建
- https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2
- 来源指纹
ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8
版本比较
PostgreSQL 15 → 16: 新增收录。
以下差异保留原始字段名与英文源描述。
--- PostgreSQL 15
+++ PostgreSQL 16
@@ -1 +1,8 @@
-该版未收录
+{
+ "definition": "Sets query parameters for the next query execution, with the specified parameters passed for any parameter placeholders ( $1 etc.). Example: INSERT INTO tbl1 VALUES ($1, $2) \\bind 'first value' 'second value' \\g This also works for query-execution commands besides \\g , such as \\gx and \\gset . This command causes the extended query protocol (see Section 55.1.2 ) to be used, unlike normal psql operation, which uses the simple query protocol. So this command can be useful to test the extended query protocol from psql. (The extended query protocol is used even if the query has no parameters and this command specifies zero parameters.) This command affects only the next query executed; all subsequent queries will use the simple query protocol by default.",
+ "modifiers": [],
+ "signature": "\\bind [ parameter ] ...",
+ "spellings": [
+ "\\bind"
+ ]
+}
比较已记录的接口与属性,排除来源指纹和构建元数据。某个样本中没有记录,不能据此判断实际引入或移除的版本。
相关条目
导出 JSON · 返回psql 命令 · 收录范围为 PostgreSQL 16 至 20;最早采样版本不一定是实际引入版本。