Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: [GENERAL] getting list of tables from command line

From: David Fetter <david(at)fetter.org>
Date: Wed Oct 31 2007 - 13:13:50 EDT


On Wed, Oct 31, 2007 at 08:01:41AM -0700, Craig White wrote:
> I wrote a little script to individually back up table schemas, table
> data and then vacuum the table and it works nicely but I wanted a
> way to query a database and get a text file with just the table
> names and cannot figure out a way to do that.

This should do it. :)

psql -At your_db <<EOT > pg_tables
SELECT quote_ident(table_schema) || '.' || quote_ident(table_name) FROM information_schema.tables
WHERE
    table_schema NOT IN (

        'information_schema',
        'pg_catalog'

    )
AND
    table_type = 'BASE TABLE';
EOT Cheers,
David.
-- 
David Fetter <
david(at)fetter.org> 
http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: 
http://www.postgresql.org/about/donate

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings
Received on Wed Oct 31 16:07:27 2007

This archive was generated by hypermail 2.1.8 : Mon Jun 16 2008 - 19:09:57 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library