We’ll see how to write queries in your editor, format output based on content and how to get info on everything.
1. Use your editor to write queries:
Tell the terminal what editory to use with from your bash shell export EDITOR=subl
, then in psql type:
psql> \e
It will open SublimeText with the last query. Close the file and the query will run.
2. Turn too long columns into lines:
psql> \x auto
Postgres will then use the most intelligible way to display the records.
3. Use \d
to get info on anything:
Info about current database:
psql> \d
More info about current database:
psql> \d+
Info about a table:
psql> \d t_table_name
Info about functions:
psql> \df
See about the 39 other \d commands with:
psql> \?