Re: getting list of tables from command line - Mailing list pgsql-general

From David Fetter
Subject Re: getting list of tables from command line
Date
Msg-id 20071031171350.GG10414@fetter.org
Whole thread Raw
In response to getting list of tables from command line  (Craig White <craigwhite@azapple.com>)
List pgsql-general
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@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

pgsql-general by date:

Previous
From: "T.J. Adami"
Date:
Subject: Re: Replacing RDBMS
Next
From: João Paulo Zavanela
Date:
Subject: Re: Install plJava