Re: Dump SQL DDL of all functions in DB

Lists: pgsql-admin
From: "Bradley Holbrook, Servillian Technology" <bholbrook(at)servillian(dot)com>
To: <pgsql-admin(at)postgresql(dot)org>
Subject: Dump SQL DDL of all functions in DB
Date: 2011-08-03 23:35:59
Message-ID: 044501cc5236$1b376ab0$51a64010$@servillian.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

Anyone know how to dump the DDL of every function in a schema into one file?

Essentially, I'd like to do something like:

'functions ddl dump cmd' public functions.sql

Bradley A Holbrook

Sr. Web Developer

Servillian Technology Ltd

<http://www.servillian.com/> http://www.servillian.com

<mailto:bholbrook(at)servillian(dot)com> bholbrook(at)servillian(dot)com

<mailto:bholbrook(at)telus(dot)blackberry(dot)net> bholbrook(at)telus(dot)blackberry(dot)net

Cell: (250) 309 - 7408

Office: (250) 260 - 4351 ext. 13

*************************************

For up to the minute news, support notifications and other pertinant
information regarding your website or related services, you can use the
following resources:

<http://twitter.com/#!/Servillian> Twitter |
<http://www.facebook.com/pages/Servillian-Technology-Ltd/144527612254727>
Facebook | <http://support.servillian.ca/> Support Website


From: Joe Conway <mail(at)joeconway(dot)com>
To: "Bradley Holbrook, Servillian Technology" <bholbrook(at)servillian(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Dump SQL DDL of all functions in DB
Date: 2011-08-09 15:25:27
Message-ID: 4E415167.3010901@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

On 08/03/2011 04:35 PM, Bradley Holbrook, Servillian Technology wrote:
> Anyone know how to dump the DDL of every function in a schema into one file?
>
> Essentially, I’d like to do something like:
>
> ‘functions ddl dump cmd’ public functions.sql

The easiest way is probably to do a schema-only dump and then edit the
result to eliminate everything you don't want. E.g.:

pg_dump --schema-only --schema=foobar test

Note that "--schema-only" means object definitions without data whereas
"--schema=foobar" is saying to only consider objects in the schema
called foobar. The work "schema" here has two different meanings.

HTH,

Joe

--
Joe Conway
credativ LLC: http://www.credativ.us
Linux, PostgreSQL, and general Open Source
Training, Service, Consulting, & 24x7 Support


From: Jerry Sievers <gsievers19(at)comcast(dot)net>
To: "Bradley Holbrook\, Servillian Technology" <bholbrook(at)servillian(dot)com>
Cc: <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Dump SQL DDL of all functions in DB
Date: 2011-08-09 15:55:39
Message-ID: 8739hay3yc.fsf@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

"Bradley Holbrook, Servillian Technology" <bholbrook(at)servillian(dot)com>
writes:

> Anyone know how to dump the DDL of every function in a schema into one file?
>
> Essentially, Iùd like to do something like:
>
> øfunctions ddl dump cmdù public functions.sql

select pg_get_functiondef(p.oid) || ';'
from pg_proc p
join pg_namespace n on p.pronamespace = n.oid
where n.nspname = 'public'
;
psql -Atq -f...

HTH

> Bradley A Holbrook
>
> Sr. Web Developer
>
> Servillian Technology Ltd
>
> http://www.servillian.com
>
> bholbrook(at)servillian(dot)com
>
> bholbrook(at)telus(dot)blackberry(dot)net
>
> Cell: (250) 309 ó 7408
>
> Office: (250) 260 ó 4351 ext. 13
>
> *************************************
>
> For up to the minute news, support notifications and other pertinant information regarding your website or related
> services, you can use the following resources:
>
> Twitter | Facebook | Support Website
>

--
Jerry Sievers
Postgres DBA/Development Consulting
e: postgres(dot)consulting(at)comcast(dot)net
p: 305.321.1144