↑↓ 选择 ↵ 打开 ⌫ 改范围 完整检索页

pgsql.cc 提供对 postgresql.org 官网内容的中文翻译,由 Pigsty 团队维护。

百科 / psql 命令 / 脚本与帮助

\set

设置 psql 变量 name 为 value ,如果给出多个值,则设置为所有值的连接。如果只给出一个参数,则将变量设置为空字符串值。要取消变量设置,请使用 \unset 命令。

当前查看 PostgreSQL 18.6。

说明

设置 psql 变量 name 为 value ,如果给出多个值,则设置为所有值的连接。如果只给出一个参数,则将变量设置为空字符串值。要取消变量设置,请使用 \unset 命令。

客户端
psql 18.6
区分大小写的写法
\set

用法

\set [ name [ value [ ... ] ] ]

本版手册中的写法

命令手册中的后缀修饰符
\set此语法签名未列出

手册定义

\set [ name [ value [ ... ] ] ]

设置psql变量name为value,如果给出多个值,则设置为所有值的连接。如果只给出一个参数,则将变量设置为空字符串值。要取消变量设置,请使用\unset命令。

\set没有任何参数时,显示当前设置的所有psql变量的名称和值。

有效的变量名可以包含字母、数字和下划线。有关详细信息,请参见下面的变量。变量名区分大小写。

某些变量是特殊的,它们控制psql的行为或者自动设置以反映连接状态。这些变量在下面的变量中有文档记录。

注意

这个命令与SQL命令SET无关。

相关条目

文档与源码

来源构建
版本
18.6
构建
https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2
来源指纹
ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8

版本比较

PostgreSQL 12 → 13: 属性变化。

以下差异保留原始字段名与英文源描述。

--- PostgreSQL 12
+++ PostgreSQL 13
@@ -1,5 +1,5 @@
 {
-  "definition": "Sets the psql variable name to value , or if more than one value is given, to the concatenation of all of them. If only one argument is given, the variable is set to an empty-string value. To unset a variable, use the \\unset command. \\set without any arguments displays the names and values of all currently-set psql variables. Valid variable names can contain letters, digits, and underscores. See the section Variables below for details. Variable names are case-sensitive. Certain variables are special, in that they control psql 's behavior or are automatically set to reflect connection state. These variables are documented in Variables , below. Note This command is unrelated to the SQL command SET .",
+  "definition": "Sets the psql variable name to value , or if more than one value is given, to the concatenation of all of them. If only one argument is given, the variable is set to an empty-string value. To unset a variable, use the \\unset command. \\set without any arguments displays the names and values of all currently-set psql variables. Valid variable names can contain letters, digits, and underscores. See Variables below for details. Variable names are case-sensitive. Certain variables are special, in that they control psql 's behavior or are automatically set to reflect connection state. These variables are documented in Variables , below. Note This command is unrelated to the SQL command SET .",
   "modifiers": [],
   "signature": "\\set [ name [ value [ ... ] ] ]",
   "spellings": [

比较已记录的接口与属性,排除来源指纹和构建元数据。某个样本中没有记录,不能据此判断实际引入或移除的版本。

相关条目

导出 JSON · 返回psql 命令 · 收录范围为 PostgreSQL 10 至 20;最早采样版本不一定是实际引入版本。