Re: pg_dump options and perhaps 'Enhancement request'

From: Reece Hart <reece(at)in-machina(dot)com>
To: Terry Yapt <pgsql(at)technovell(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: pg_dump options and perhaps 'Enhancement request'
Date: 2003-05-08 23:22:30
Message-ID: 1052436150.7791.81.camel@tallac
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gene(dot)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(at)in-machina(dot)com, GPG: 0x25EC91A0

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Brian Maguire 2003-05-09 03:27:03 informix to postgres tools?
Previous Message Tom Lane 2003-05-08 22:51:58 Re: Error executing dbcreate