Skip to content

Instantly share code, notes, and snippets.

@nvdarekar
Forked from nepsilon/3-postgres-tips.md
Created March 8, 2016 05:08
Show Gist options
  • Select an option

  • Save nvdarekar/fdaf23249b7c35a69984 to your computer and use it in GitHub Desktop.

Select an option

Save nvdarekar/fdaf23249b7c35a69984 to your computer and use it in GitHub Desktop.
3 tips for a better PostgreSQL usage
# 1. Use your editor to write queries:
# Tell the terminal what editory to use
$ 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> \?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment