Re: [PERFORM] [NOVICE] \d output to a file

2004-12-15 Thread Tom Lane
Geoffrey [EMAIL PROTECTED] writes:
 sarlav kumar wrote:
 I would like to write the output of the \d command on all tables in a
 database to an output file.

 What is the OS?  On any UNIX variant you can do:
 echo '\d' | psql  outputfile

Or use \o:

regression=# \o zzz1
regression=# \d
regression=# \o
regression=# \d
 List of relations
 Schema | Name  | Type  |  Owner
+---+---+--
 public | pg_ts_cfg | table | postgres
 public | pg_ts_cfgmap  | table | postgres
 public | pg_ts_dict| table | postgres
 public | pg_ts_parser  | table | postgres
 public | t_test| table | postgres
 public | test_tsvector | table | postgres
(6 rows)

regression=# \q
$ cat zzz1
 List of relations
 Schema | Name  | Type  |  Owner
+---+---+--
 public | pg_ts_cfg | table | postgres
 public | pg_ts_cfgmap  | table | postgres
 public | pg_ts_dict| table | postgres
 public | pg_ts_parser  | table | postgres
 public | t_test| table | postgres
 public | test_tsvector | table | postgres
(6 rows)

$

regards, tom lane

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


Re: [PERFORM] [NOVICE] \d output to a file

2004-12-15 Thread Ragnar HafstaĆ°
On Wed, 2004-12-15 at 11:50 -0500, Tom Lane wrote:
 Geoffrey [EMAIL PROTECTED] writes:
  sarlav kumar wrote:
  I would like to write the output of the \d command on all tables in a
  database to an output file.
 
  What is the OS?  On any UNIX variant you can do:
  echo '\d' | psql  outputfile
 
 Or use \o:
 
 regression=# \o zzz1
 regression=# \d
or:
=# \d *
to get all tables as th OP wanted

 regression=# \o

gnari



---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [PERFORM] [NOVICE] \d output to a file

2004-12-15 Thread Geoffrey
sarlav kumar wrote:
Hi All,
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? Any help in this regard
would be really appreciated.
What is the OS?  On any UNIX variant you can do:
echo '\d' | psql  outputfile
But this will get you the system tables as well I think.
Alternately you could do something like:
for table in $(listoftables); do
echo '\d' | psql
done  outputfile
--
Until later, Geoffrey
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
  http://www.postgresql.org/docs/faqs/FAQ.html