Skip to content

Instantly share code, notes, and snippets.

@mikamboo
Last active December 17, 2015 11:48
Show Gist options
  • Save mikamboo/5604508 to your computer and use it in GitHub Desktop.
Save mikamboo/5604508 to your computer and use it in GitHub Desktop.
Raccourcis commandes utiles sous PostgreSQL

PostgreSQL commands

Show databases :

postgresql: \l
postgresql: SELECT datname FROM pg_database;

Show tables :

postgresql: \d
postgresql: SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';

Show table columns :

postgresql: \d table
postgresql: SELECT column_name FROM information_schema.columns WHERE table_name ='table';

Utils

SELECT and COUNT in same query :

  postgresql: SELECT "ddd_type_flux", count(*) AS "count" 
              FROM "ddd_demande" WHERE 1 = 1 GROUP BY "ddd_type_flux" ORDER BY "count";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment