Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

With pg16 the \bind command was added to psql

\bind [ parameter ] ...
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.

This is extremely helpful when debugging sql that you've copy pasted from a project or app.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
💡
Ideas
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.