pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
dumping only table definitions
6+ messages / 5 participants
[nested] [flat]

* dumping only table definitions
@ 2018-06-29 22:30 Kevin Brannen <KBrannen@efji.com>
  2018-06-29 22:39 ` Re: dumping only table definitions Alvaro Herrera <alvherre@2ndquadrant.com>
  2018-06-29 22:44 ` Re: dumping only table definitions Melvin Davidson <melvin6925@gmail.com>
  0 siblings, 2 replies; 6+ messages in thread

From: Kevin Brannen @ 2018-06-29 22:30 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

I'm trying to figure out how to dump only the table definitions, well those and things they need directly, like sequences & types. What I do NOT want are all the millions (not literally but it feels like it :)) of functions we have. Triggers would be all right if I must, as we only have a few of those.

I've tried various combinations of args to pg_dump, with -s being what I'd like to work, but I still get all the functions.

I suppose I could filter it with Perl or Awk, but that could be tricky. In fact, the best my searching could find is to do:

     pg_dump -s databasename | awk 'RS="";/CREATE TABLE[^;]*;/'

which fails in some interesting ways.

I could dump the schema (with functions) then load it into another DB then programmatically drop all the functions before dumping that with pg_dump, but again why should I have to.

Is there any Pg tool that gives me just the table defs or am I going to have to write my own?

Thanks,
Kevin
This e-mail transmission, and any documents, files or previous e-mail messages attached to it, may contain confidential information. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient, you are hereby notified that any disclosure, distribution, review, copy or use of any of the information contained in or attached to this message is STRICTLY PROHIBITED. If you have received this transmission in error, please immediately notify us by reply e-mail, and destroy the original transmission and its attachments without reading them or saving them to disk. Thank you.

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: dumping only table definitions
  2018-06-29 22:30 dumping only table definitions Kevin Brannen <KBrannen@efji.com>
@ 2018-06-29 22:39 ` Alvaro Herrera <alvherre@2ndquadrant.com>
  2018-06-29 22:43   ` Re: dumping only table definitions Tom Lane <tgl@sss.pgh.pa.us>
  2018-06-30 16:11   ` Re: dumping only table definitions Vick Khera <vivek@khera.org>
  1 sibling, 2 replies; 6+ messages in thread

From: Alvaro Herrera @ 2018-06-29 22:39 UTC (permalink / raw)
  To: Kevin Brannen <KBrannen@efji.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On 2018-Jun-29, Kevin Brannen wrote:

> I'm trying to figure out how to dump only the table definitions, well those and things they need directly, like sequences & types. What I do NOT want are all the millions (not literally but it feels like it :)) of functions we have. Triggers would be all right if I must, as we only have a few of those.

Try "pg_dump -Fc" followed by pg_restore -l.  You can edit the list
emitted there, then use it with pg_restore -L.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: dumping only table definitions
  2018-06-29 22:30 dumping only table definitions Kevin Brannen <KBrannen@efji.com>
  2018-06-29 22:39 ` Re: dumping only table definitions Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2018-06-29 22:43   ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 6+ messages in thread

From: Tom Lane @ 2018-06-29 22:43 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Kevin Brannen <KBrannen@efji.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> On 2018-Jun-29, Kevin Brannen wrote:
>> I'm trying to figure out how to dump only the table definitions, well those and things they need directly, like sequences & types. What I do NOT want are all the millions (not literally but it feels like it :)) of functions we have. Triggers would be all right if I must, as we only have a few of those.

> Try "pg_dump -Fc" followed by pg_restore -l.  You can edit the list
> emitted there, then use it with pg_restore -L.

I think something involving "--tables '*.*'" might work, too.
Be careful about shell-command quoting.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: dumping only table definitions
  2018-06-29 22:30 dumping only table definitions Kevin Brannen <KBrannen@efji.com>
  2018-06-29 22:39 ` Re: dumping only table definitions Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2018-06-30 16:11   ` Vick Khera <vivek@khera.org>
  1 sibling, 0 replies; 6+ messages in thread

From: Vick Khera @ 2018-06-30 16:11 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On Fri, Jun 29, 2018 at 6:39 PM, Alvaro Herrera <alvherre@2ndquadrant.com>
wrote:

> On 2018-Jun-29, Kevin Brannen wrote:
>
> > I'm trying to figure out how to dump only the table definitions, well
> those and things they need directly, like sequences & types. What I do NOT
> want are all the millions (not literally but it feels like it :)) of
> functions we have. Triggers would be all right if I must, as we only have a
> few of those.
>
> Try "pg_dump -Fc" followed by pg_restore -l.  You can edit the list
> emitted there, then use it with pg_restore -L.
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: dumping only table definitions
  2018-06-29 22:30 dumping only table definitions Kevin Brannen <KBrannen@efji.com>
@ 2018-06-29 22:44 ` Melvin Davidson <melvin6925@gmail.com>
  2018-06-29 22:56   ` RE: dumping only table definitions Kevin Brannen <KBrannen@efji.com>
  1 sibling, 1 reply; 6+ messages in thread

From: Melvin Davidson @ 2018-06-29 22:44 UTC (permalink / raw)
  To: Kevin Brannen <KBrannen@efji.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On Fri, Jun 29, 2018 at 6:30 PM, Kevin Brannen <KBrannen@efji.com> wrote:

> I’m trying to figure out how to dump only the table definitions, well
> those and things they need directly, like sequences & types. What I do NOT
> want are all the millions (not literally but it feels like it J) of
> functions we have. Triggers would be all right if I must, as we only have a
> few of those.
>
>
>
> I’ve tried various combinations of args to pg_dump, with -s being what I’d
> like to work, but I still get all the functions.
>
>
>
> I suppose I could filter it with Perl or Awk, but that could be tricky. In
> fact, the best my searching could find is to do:
>
>
>
>      pg_dump -s databasename | awk 'RS="";/CREATE TABLE[^;]*;/'
>
>
>
> which fails in some interesting ways.
>
>
>
> I could dump the schema (with functions) then load it into another DB then
> programmatically drop all the functions before dumping that with pg_dump,
> but again why should I have to.
>
>
>
> Is there any Pg tool that gives me just the table defs or am I going to
> have to write my own?
>
>
>
> Thanks,
>
> Kevin
> This e-mail transmission, and any documents, files or previous e-mail
> messages attached to it, may contain confidential information. If you are
> not the intended recipient, or a person responsible for delivering it to
> the intended recipient, you are hereby notified that any disclosure,
> distribution, review, copy or use of any of the information contained in or
> attached to this message is STRICTLY PROHIBITED. If you have received this
> transmission in error, please immediately notify us by reply e-mail, and
> destroy the original transmission and its attachments without reading them
> or saving them to disk. Thank you.
>

> What I do NOT want are all the millions (not literally but it feels like
it J) of functions we have.

It sounds like you would best be served by installing pg_extractor. In
essence, it is a super flexible version of pg_dump. You have your choice of
exactly what you want to dump.

https://github.com/omniti-labs/pg_extractor

-- 
*Melvin Davidson*
*Maj. Database & Exploration Specialist*
*Universe Exploration Command – UXC*
Employment by invitation only!

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* RE: dumping only table definitions
  2018-06-29 22:30 dumping only table definitions Kevin Brannen <KBrannen@efji.com>
  2018-06-29 22:44 ` Re: dumping only table definitions Melvin Davidson <melvin6925@gmail.com>
@ 2018-06-29 22:56   ` Kevin Brannen <KBrannen@efji.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Kevin Brannen @ 2018-06-29 22:56 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On Fri, Jun 29, 2018 at 6:30 PM, Kevin Brannen <KBrannen@efji.com<mailto:KBrannen@efji.com>> wrote:
I’m trying to figure out how to dump only the table definitions, well those and things they need directly, like sequences & types. What I do NOT want are all the millions (not literally but it feels like it ☺) of functions we have. Triggers would be all right if I must, as we only have a few of those.

Melvin wrote:

> > What I do NOT want are all the millions (not literally but it feels like it ☺) of functions we have.

> It sounds like you would best be served by installing pg_extractor. In essence, it is a super flexible version of pg_dump. You have your choice of exactly what you want to dump.

> https://github.com/omniti-labs/pg_extractor
Thanks Melvin, that looks like it would do what I want. If it doesn’t, I’ll try Alvaro’s and Tom’s suggestions.

Kevin
This e-mail transmission, and any documents, files or previous e-mail messages attached to it, may contain confidential information. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient, you are hereby notified that any disclosure, distribution, review, copy or use of any of the information contained in or attached to this message is STRICTLY PROHIBITED. If you have received this transmission in error, please immediately notify us by reply e-mail, and destroy the original transmission and its attachments without reading them or saving them to disk. Thank you.


^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2018-06-30 16:11 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-06-29 22:30 dumping only table definitions Kevin Brannen <KBrannen@efji.com>
2018-06-29 22:39 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2018-06-29 22:43   ` Tom Lane <tgl@sss.pgh.pa.us>
2018-06-30 16:11   ` Vick Khera <vivek@khera.org>
2018-06-29 22:44 ` Melvin Davidson <melvin6925@gmail.com>
2018-06-29 22:56   ` Kevin Brannen <KBrannen@efji.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox