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

From hubert depesz lubaczewski
Subject Re: getting list of tables from command line
Date
Msg-id 20071102080920.GB16757@depesz.com
Whole thread Raw
In response to Re: getting list of tables from command line  (Craig White <craigwhite@azapple.com>)
List pgsql-general
On Thu, Nov 01, 2007 at 08:03:08PM -0700, Craig White wrote:
> *** begin pg_table_dump.scr ***
> #/bin/sh
> #
> # Script to identify tables, backup schema and data separately and
> # then finally, vacuum each table
> #
> DB_NAME=MY_DB
> BACKUP_PATH=/home/backup/postgres/production
> MY_SCHEMA=public
> PG_USER=craig
> #
> psql -U $PG_USER \
>   $DB_NAME \
>   -c "SELECT tablename FROM pg_tables WHERE \
>   schemaname = "\'$MY_SCHEMA\'";" | \
>   grep -v 'tablename' | \
>   grep -v [\--*] | \
>   grep -v rows\) > $BACKUP_PATH/pg_tables

instead of these 3 grep -v, i would suggest to use -qAt switches to
psql:
psql -U $PG_USER -d $DB_NAME -qAt -c "..."

depesz

--
quicksil1er: "postgres is excellent, but like any DB it requires a
highly paid DBA.  here's my CV!" :)
http://www.depesz.com/ - blog dla ciebie (i moje CV)

pgsql-general by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: young guy wanting (Postgres DBA) ammo
Next
From: "Moiz Kothari"
Date:
Subject: Re: Number to Words Conversion