1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2024-11-02 17:17:57 +01:00
tldr/pages/common/psql.md

19 lines
562 B
Markdown
Raw Normal View History

2014-05-08 16:10:08 +02:00
# psql
> PostgreSQL command-line client
2014-05-12 13:44:31 +02:00
- Connect to *database*. It connects to localhost using default port *5432* with default user
2014-05-08 16:10:08 +02:00
`psql {{database}}`
2014-05-12 13:44:31 +02:00
- Connect to *database* on given server *host* running on given *port* with *username* given
2014-05-08 16:10:08 +02:00
2014-05-12 13:44:31 +02:00
`psql -h {{host}} -p {{port}} -U {{username}} {{database}}`
2014-05-08 16:10:08 +02:00
2014-05-12 13:44:31 +02:00
- Run single *query* against the given *database*. Note: useful in shell scripts
2014-05-08 16:10:08 +02:00
2014-05-12 13:44:31 +02:00
`psql -c '{{query}}' {{database}}`
2014-05-08 16:10:08 +02:00
2014-05-12 22:54:47 +02:00
- Run several queries against the given *database*. Note: useful in shell scripts
2014-05-08 16:10:08 +02:00
2014-05-12 22:54:47 +02:00
`psql {{database}} <<< "{{query1}}; {{query2}}"`