\gexec
Sends the current query buffer to the server, then treats each column of each row of the query's output (if any) as an SQL statement to be executed. For example, to create an index on each column of my_table :
当前阅读 PG 18·选择有来源记录的版本
此版本暂无所选语言的定义,以下显示原始英文内容。
- Client
- psql 18.6
- Case-sensitive spelling
- \gexec
- command
- \gexec
- manual path
- app-psql.html#APP-PSQL-META-COMMAND-GEXEC
- modifiers
- 未知
- signature
- \gexec
- spellings
- \gexec
版本定义 PG 18
\gexec-
Sends the current query buffer to the server, then treats each column of each row of the query's output (if any) as an SQL statement to be executed. For example, to create an index on each column of
my_table:=>
SELECT format('create index on my_table(%I)', attname)->FROM pg_attribute->WHERE attrelid = 'my_table'::regclass AND attnum > 0->ORDER BY attnum->\gexecCREATE INDEX CREATE INDEX CREATE INDEX CREATE INDEXThe generated queries are executed in the order in which the rows are returned, and left-to-right within each row if there is more than one column. NULL fields are ignored. The generated queries are sent literally to the server for processing, so they cannot be psql meta-commands nor contain psql variable references. If any individual query fails, execution of the remaining queries continues unless
ON_ERROR_STOPis set. Execution of each query is subject toECHOprocessing. (SettingECHOtoallorqueriesis often advisable when using\gexec.) Query logging, single-step mode, timing, and other query execution features apply to each generated query as well.If the current query buffer is empty, the most recently sent query is re-executed instead.
精确保留大小写的命令写法
\gexec
Spellings in this manual definition
| Command | Documented suffix modifiers |
|---|---|
| \gexec | None listed in this signature |
比较版本
来源引用
定义来源
center · PostgreSQL 18 · ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8
正文语言: en · ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8