Languages
[Edit]
EN

Postgres - execute SQL query from command line

9 points
Created by:
Maryamcc
481

In this short article, we would like to show how to execute a query on the Postgress database from the command line.

Quick solution:

echo "SELECT 1" | psql postgres://my-username:my-password@localhost:5432/my-database ON_ERROR_STOP=1 --single-transaction

See also

  1.  PostgreSQL - execute SQL query from file using command line
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join