Re: getting list of tables from command line

From: David Fetter <david(at)fetter(dot)org>
To: Craig White <craigwhite(at)azapple(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: getting list of tables from command line
Date: 2007-10-31 17:13:50
Message-ID: 20071031171350.GG10414@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message T.J. Adami 2007-10-31 17:19:51 Server's Locale
Previous Message T.J. Adami 2007-10-31 17:02:55 Re: getting list of tables from command line