Wiki / psql Commands / Query execution
\bind
Sets query parameters for the next query execution, with the specified parameters passed for any parameter placeholders ( $1 etc.).
Reading PostgreSQL 18.6.
Description
Sets query parameters for the next query execution, with the specified parameters passed for any parameter placeholders ( $1 etc.).
- Client
- psql 18.6
- Case-sensitive spelling
- \bind
Usage
\bind [ parameter ] ...Spellings in this manual definition
| Command | Documented suffix modifiers |
|---|---|
| \bind | None listed in this signature |
Manual definition
\bind[parameter] ...-
Sets query parameters for the next query execution, with the specified parameters passed for any parameter placeholders (
$1etc.).Example:
INSERT INTO tbl1 VALUES ($1, $2) \bind 'first value' 'second value' \g
This also works for query-execution commands besides
\g, such as\gxand\gset.This command causes the extended query protocol (see Section 54.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.
Related entries
Documentation and source
Source build
- Version
- 18.6
- Build
- https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2
- Source fingerprint
ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8
Compare versions
PostgreSQL 17 → 18: changed.
--- PostgreSQL 17
+++ PostgreSQL 18
@@ -1,5 +1,5 @@
{
- "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 53.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.",
+ "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 54.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": [
Compares recorded interfaces and attributes. Source fingerprints and build metadata are excluded; an absent sample is not proof of the introduction or removal release.
Related entries
Export JSON · Back to psql Commands · Recorded in PostgreSQL 16 through 20; the first sample is not necessarily its introduction.