postgresql logo

PostgreSQL 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?
  • How can I get the list of databases in Postgres like “show databases” in MySQL?

In this quick tutorial, we’ll answer these questions, along with some other common commands which are useful.

PostgreSQL doesn’t work with original MySQL commands, but it gives similar functionality with its own commands:

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

postgresql: \l
postgresql: SELECT datname FROM pg_database;

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

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

If there are any other equivalent commands you’d like to learn for Postgres which we’ve missed above, feel free to let us know in the comments section and we’ll get them added.




  1. August 25, 2009  6:49 pm by tulip Reply

    COOL! please add more!

  2. October 22, 2009  10:09 am by BadGirl88 Reply

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

  3. October 23, 2009  9:40 am by Settor17 Reply

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

  4. May 3, 2010  11:15 pm by Mark Manning Reply

    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.

  5. November 23, 2010  8:35 am by Felix Egli Reply

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

  6. February 5, 2011  2:18 pm by calamuchita turismo Reply

    and utilised to create a rustic

  7. March 25, 2011  10:59 pm by Nande! Reply

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

  8. May 8, 2011  8:29 pm by Rob Rasner Facebook Reply

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

  9. May 13, 2011  8:46 am by uotos Reply

    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

  10. June 2, 2011  5:34 am by what is a hemroid Reply

    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 :)

  11. February 3, 2012  6:22 am by Nisar Reply


  12. Pingback : Web Development | Pearltrees

  13. June 21, 2012  12:52 pm by Manish Reply

    Thanks mate.. really appreciated..

  14. August 21, 2012  8:23 am by Aashish Kiran Reply

    Thank you, your blog helped.
    Keeping posting blogs.

  15. October 12, 2012  8:03 am by NULL Reply

    ', (delete from *)

  16. November 8, 2012  5:15 am by Saji Nediyanchath Reply

    Thanks. Was looking for this information.

  17. Pingback : Postgresql: show tables, show databases, show columns, describe table « My private-public notes

  18. November 15, 2012  10:42 pm by Miguel Reply

    en mysql:
    SELECT * FROM information_schema.columns WHERE table_name = 'tableName' AND table_schema = 'bdName';
    en postgresql:
    SELECT * FROM information_schema.columns WHERE table_name = 'tableName' AND table_catalog = 'bdName';

  19. December 7, 2012  8:00 pm by Greg Reply

    thanks , this was of great help

  20. December 10, 2012  1:20 am by Thomas Reply

    Yeah, please Add more !

    Very cool thanks, coming up from MySQL, this tips saved me some time working on production during a demo :D.

    example : \c database to use another database. equivalent to use database; in mysql

  21. Pingback : PostgreSQL for MySQLlers | Blog

  22. February 15, 2013  8:30 am by lbrcold Reply

    Thanks. It very helpfull.

  23. February 24, 2013  11:48 am by Gerard Wills Reply

    In PostgreSQL we often want to know what the structure of the table is, how many records are in the table and what the table contains. The following psql commands will provide this.

    select column_name, is_nullable, data_type,
    character_maximum_length as max_length, numeric_precision as precision
    from information_schema.columns where table_name = 'applicant';

    select count(*) from applicant;

    select * from applicant order by 1;

  24. Pingback : PostgreSQL basic command | imron02

  25. May 22, 2013  4:18 am by nice Newport Beach massage therapy Reply

    I got this website from my pal who informed me on the topic of this website and now this time I
    am visiting this site and reading very informative articles or reviews

  26. May 27, 2013  3:52 pm by Best emac parts Reply

    Good day! Do you know if they make any plugins to protect against hackers?

    I'm kinda paranoid about losing everything I've worked hard
    on. Any tips?

  27. June 7, 2013  11:24 pm by Monica Reply

    all the time i used to read smaller content that also clear their motive, and that is
    also happening with this article which I am reading at this place.

Leave a reply


Your email address will not be published.