Re: pg_dump options and perhaps 'Enhancement request' - Mailing list pgsql-general

From Reece Hart
Subject Re: pg_dump options and perhaps 'Enhancement request'
Date
Msg-id 1052436150.7791.81.camel@tallac
Whole thread Raw
In response to pg_dump options and perhaps 'Enhancement request'  (Terry Yapt <pgsql@technovell.com>)
List pgsql-general
On Thu, 2003-05-08 at 13:11, Terry Yapt wrote:
> I don't know if I can do this stuffs.  If not I would like to get it in
> the future.  Thanks.
>
> 1-) Are there any way to do a pg_dump without '--' COMMENTS ?  For
> example, I don't like to have this in my output file:
> --
> -- TOC entry 19 (OID 26027)
> -- Name: TABLE news; Type: COMMENT; Schema: www; Owner: www
> --
>
> 2-) The same for the 'blank' lines.  Are there a lot of in the output
> file.

The plain-text pg_dump output is just that and you can use various
command line tools to strip out stuff you don't like.  A simple solution
for most cases:

$ pg_dump [args] | egrep -v '^--|^$' >backup.sql

HOWEVER, if you have the diabolical case of a table whose first column
is a text type AND a row in which that first column's text begins with
'--', then you'll strip those too.  I think you're safe otherwise.
(newlines are translated as '\n').

> 3-) Are there any way to get the output file with schemas in all
> table_names ?
> I would like to get this:
> COMMENT ON TABLE www.fo_temas IS 'xxxx.';  -- instead of:
> COMMENT ON TABLE     fo_temas IS 'xxxx.';

This is fairly easy with a simple perl script.
--
Reece Hart, Ph.D.                       rkh@gene.com, http://www.gene.com/
Genentech, Inc.                         650/225-6133 (voice), -5389 (fax)
Bioinformatics and Protein Engineering
1 DNA Way, MS-93                        http://www.in-machina.com/~reece/
South San Francisco, CA  94080-4990     reece@in-machina.com, GPG: 0x25EC91A0


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Error executing dbcreate
Next
From: "Brian Maguire"
Date:
Subject: informix to postgres tools?