Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

[GENERAL] getting list of tables from command line

From: Craig White <craigwhite(at)azapple.com>
Date: Wed Oct 31 2007 - 11:01:41 EDT


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.

my script looks like this...
(all I want is to get a list of the tables into a text file pg_tables)

#/bin/sh
#
DB_NAME=whatever
#
for i in `cat pg_tables`
do
  pg_dump --username=postgres \
--schema=db
--table=$i \
--schema-only \

    $DB_NAME > schemas/$i.sql
  pg_dump --username=postgres \
--schema=db \
--table=$i \
--data-only \

    $DB_NAME > data/$i.sql
  vacuumdb --username=postgres \

   --dbname=$DB_NAME \
   --table=db.$i \
   --verbose \
   --full

done

Is there a way to do that?

Craig

PS there's a lack of cohesion between various commands such as vacuumdb and pg_dump for things like '--schema'

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match
Received on Wed Oct 31 13:10:51 2007

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


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