Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > Re: pg_dump and...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 15185 of 17602
Post > Topic >>

Re: pg_dump and schemas

by b.wood@[EMAIL PROTECTED] ("Brent Wood") Apr 6, 2008 at 07:16 AM

Hi Rusty,

In which case can you not include the text around the schema & table
creati=
on commands to ensure other instances of "public" do not match the string?

I'm not sure exactly what the pg_dump output contains, but you could use
so=
mething like:

cat pg_dump.sql | sed 's/CREATE SCHEMA "public"/CREATE SCHEMA
"new_schema"/=
' | \
sed 's/CREATE TABLE "public"./CREATE TABLE "new_schema"./' >
new_schema.sql

This should avoid any ambiguity as to which instances of "public" you want
=
changed in the pg_dump sql file.

I think adding sup****t for changing schema names in pg_dump would make it
u=
nnecessarily complex, as why just schemas? Also rename databases, tables,
c=
olumns, index names, change comments...=20

I've yet to find something like this I couldn't do with sed, & if there
was=
 there is always awk for the truly desparate :-)
pg_dump generates the dump, reliably, simply & safely. Any change you want
=
from the original is not, IMHO, the role of a backup program. That should
O=
NLY back up a replica of your data. Make changes afterwards if you like,
bu=
t a backup program shouldn't modify your data.=20

Just my 02c, & I ain't no Postgres developer, so I'm not speaking for them
=
in this....

Cheers,

  Brent Wood



Hi Brent,

It's not he best solution, because we could have fields containing=20=20
"public" in their names and sed would happily change those to test1 as=20=
=20
well.

I'm looking for a safer solution, thats why it should be a part of=20=20
pg_dump.

Rusty

On Apr 5, 2008, at 12:41 AM, Brent Wood wrote:

> Hi Rusty,
>
> Try passing the output through a utility like sed, already there=20=20
> under Linux , but versions that work under Windows are available=20=20
> (eg, cygwin)
>
> eg, using a pipe:   pg_dump -d.... | sed 's/public/test1/g' > dump.sql

--=20
Sent via pgsql-general mailing list (pgsql-general@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
 




 1 Posts in Topic:
Re: pg_dump and schemas
b.wood@[EMAIL PROTECTED]   2008-04-06 07:16:00 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 18:36:50 CST 2008.