Postgresql: show tables, show databases, show columns

postgresql logoPostgreSQL is one of the best database engines for an average web project and many who moves to psql from mysql (for example) often ask the following questions: what  is the analog of “show tables” in postgres? or how can I get the list of databases in postgres like “show databases” in mysql? The answers are short:

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

mysql: SHOW DATABASES
postgresql: \l
postgresql: SELECT datname FROM pg_database;

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

 
 
» You might also be interested in the following articles:
FAQ: Change forgotten or lost MySQL root password
The Simpsons are made with Linux…
Quick copy/paste MySQL Replication Manual
Dump ipcad output into sqlite3
CGI Perl scripts debugging (solve 500 Internal Server Error)



» Want to stay up to date? Subscribe to our E-MAIL or RSS feed!

13 Responses to “Postgresql: show tables, show databases, show columns”


  1. 1 tulip

    COOL! please add more!

  2. 2 BadGirl88

    While most would agree that this seems to be the endall stratagem, it is only a starting point with endless possibilities. ,

  3. 3 Settor17

    Later, Trip communicates with Archer and T’Pol as he works on the Xyrillian engine. ,

  4. 4 ?

    ??????? ???? ???
    ????? ??????????
    . ??????? ????????.

  5. 5 Mark Manning

    Actually, this is a terrible way to do the SHOW TABLES/COLUMNS/WHATEVER commands. Here is a great example: ME! :-)

    Where I work, I have no privileges on the database other than on a test database where I do my work. Even on there though I have limited privileges. Throw into this conundrum the fact that I’m trying to document the layout of all of the tables (something that has never been done here) and you suddenly get disaster. I can not log directly into the databases – I have to go through their command interpreter. Thus, I can not do the \dX options at all because I have no command line interface. If Postgresql had the SHOW XXX commands, then I could still get the layout of the tables. Because PSQL doesn’t have the SHOW XXX commands – I can’t do this. Wish it had it.

  6. 6 ovegreecy

    online ???? ????? ???? ? ????? mmorpg
    ?????? ? ?????? ???? ?????? ????? ?????? ??????
    ?????????? ?????? ???? ????????? ?????? ??? ???? ?????????
    mmorpg ???????? ????? ????????? ???? 2009 2010

  7. 7 Felix Egli

    Mark, you can use the SELECT … form.
    SELECT table_name FROM information_schema.tables WHERE table_schema = ‘public’;

  8. 8 calamuchita turismo

    and utilised to create a rustic

  9. 9 Nande!

    really awesome, just what i’ve been looking for, nothing else alike in the web.

  10. 10 Rob Rasner Facebook

    TQ for this info … I currently doing a number of these suggestions but there are many others might be new to us

  11. 11 uotos

    A reading system is an ideal tool for teaching your child to read. Essentially, this is a system that has been formulated and used specifically for teaching

  12. 12 what is a hemroid

    Excellent blog site, mate! Postgresql: show tables, show databases, show columns – Linux * Screw is basically a thing. I am launching my very own shortly i will certainly backup elements of the one you have, legally needless to say :)

  13. 13 Nisar

    Thanks

Leave a Reply




Friendly Sites:Who is behind Linux Screw?
GeekyBits³ | Bash Cures Cancer | OMG! Ubuntu!
My SysAd Blog | Web Upd8
ZEPY | Linux config Wiki | Planet Sysadmin
a non-geek's linux notes | Linux Today
TuxArena: The arena of Tux | LinuxAlt.Com
My name is Artem N. (artiomix AT gmail DOT com) and I'm Linux/Unix, Cisco systems engineer. The main idea of Linux Screw is to share relevant knowledge, skills and observations over The Web. Here you can find a lot of information related to different Linux distributions, FreeBSD, IOS as well as a other Open Source around staff. Read more ››