Search Postgresql Archives

Re: getting list of tables from command line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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)

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux