Skip site navigation (1) Skip section navigation (2)

Re: [despammed] \d output to a file

From: Kretschmer Andreas <andreas_kretschmer(at)despammed(dot)com>
To: pgsqlnovice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: [despammed] \d output to a file
Date: 2004-12-15 16:21:57
Message-ID: 20041215162157.GA6127@kaufbach.delug.de (view raw or flat)
Thread:
Lists: pgsql-novicepgsql-performance
am  Wed, dem 15.12.2004, um 10:23:54 -0500 mailte Geoffrey folgendes:
> >>I would like to write the output of the \d command on all tables in a 
> >>database to an output file. There are more than 200 tables in the 
> >>database. I am aware of \o command to write the output to a file. But, it 
> >>will be tough to do the \d for each table manually and write the output 
> >>to a file. Is there a command/ way in which I can achieve this without 
> >>having to do it for each table?
> >
> >You can write a little shell-script to list all tables via \d and parse
> >the output to generate for each table a '\d table'.
> 
> Or:
> 
> for table in $(<filethatcontainsalistofthetables); do

Yes, but you need the file called 'filethatcontainsalistofthetables' ;-)

echo "\d" | psql test_db | awk 'BEGIN{FS="|"}{if($3 ~ "Tabelle") {print "\d" $2}}' | psql test_db

It works, if the database named 'test_db' and if the output from \d in
the 3th row is 'Tabelle'.


Andreas
-- 
Diese Message wurde erstellt mit freundlicher Unterstützung eines freilau-
fenden Pinguins aus artgerechter Freilandhaltung.   Er ist garantiert frei
von Micro$oft'schen Viren. (#97922 http://counter.li.org)     GPG 7F4584DA
Was, Sie wissen nicht, wo Kaufbach ist? Hier: N 51.05082°, E 13.56889° ;-)

In response to

pgsql-novice by date

Next:From: Tom LaneDate: 2004-12-15 16:50:58
Subject: Re: \d output to a file
Previous:From: Grega BremecDate: 2004-12-15 15:35:58
Subject: Re: [PERFORM] \d output to a file

pgsql-performance by date

Next:From: Tom LaneDate: 2004-12-15 16:50:58
Subject: Re: \d output to a file
Previous:From: Grega BremecDate: 2004-12-15 15:35:58
Subject: Re: [PERFORM] \d output to a file

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group