mirror of https://github.com/CrimsonTome/tldr.git
psql: Improve page (#982)
* psql: Improve page - Removed * , this was causing problems with rendering. The node client was gobbling up the entire word ! - Changed 'query' to 'command' as it can be a postgres db command too. - Used the -f flag for running multiple commands as its a better and scalable option. * Addressing comments * Replacing against with on - Mentioning the default userwaldyrious/alt-syntax
parent
f6a41ecee9
commit
5f43335dc6
|
@ -2,22 +2,22 @@
|
||||||
|
|
||||||
> PostgreSQL command-line client.
|
> PostgreSQL command-line client.
|
||||||
|
|
||||||
- Connect to *database*. It connects to localhost using default port *5432* with default user:
|
- Connect to database. It connects to localhost using default port 5432 with default user as currently logged in user:
|
||||||
|
|
||||||
`psql {{database}}`
|
`psql {{database}}`
|
||||||
|
|
||||||
- Connect to *database* on given server *host* running on given *port* with *username* given, no password prompt:
|
- Connect to database on given server host running on given port with given username, without a password prompt:
|
||||||
|
|
||||||
`psql -h {{host}} -p {{port}} -U {{username}} {{database}}`
|
`psql -h {{host}} -p {{port}} -U {{username}} {{database}}`
|
||||||
|
|
||||||
- Connect to *database*, user will be prompted for password:
|
- Connect to database; user will be prompted for password:
|
||||||
|
|
||||||
`psql -h {{host}} -p {{port}} -U {{username}} -W {{database}}`
|
`psql -h {{host}} -p {{port}} -U {{username}} -W {{database}}`
|
||||||
|
|
||||||
- Run single *query* against the given *database*. Note: useful in shell scripts:
|
- Execute a single SQL query or PostgreSQL command on the given database. Note: useful in shell scripts:
|
||||||
|
|
||||||
`psql -c '{{query}}' {{database}}`
|
`psql -c '{{query}}' {{database}}`
|
||||||
|
|
||||||
- Run several queries against the given *database*. Note: useful in shell scripts:
|
- Execute commands from a file on the given database:
|
||||||
|
|
||||||
`echo '{{query1}}; {{query2}}' | psql {{database}}`
|
`psql {{database}} -f {{file.sql}}`
|
||||||
|
|
Loading…
Reference in New Issue