Skip to content

Instantly share code, notes, and snippets.

@danilobatistaqueiroz
Last active November 24, 2017 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danilobatistaqueiroz/b2be5ee67ae58da7ad768a606e634164 to your computer and use it in GitHub Desktop.
Save danilobatistaqueiroz/b2be5ee67ae58da7ad768a606e634164 to your computer and use it in GitHub Desktop.
Postgresql Tips

Postgres Tips

jdbc_url: jdbc:postgresql://localhost:5432/databasename

showing all databases:

SELECT datname FROM pg_database WHERE datistemplate = false;

This lists tables in the current database

SELECT table_schema,table_name FROM information_schema.tables ORDER BY table_schema,table_name;

psql commands

\list or \l: list all databases

\dt: list all tables in the current database

To switch databases: \connect database_name


Links:

https://dba.stackexchange.com/questions/1285/how-do-i-list-all-databases-and-tables-using-psql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment