pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedDatabase maintenance help
3+ messages / 2 participants
[nested] [flat]
* Database maintenance help
@ 2002-12-14 01:23 Jesus Sandoval <meli@mzt.megared.net.mx>
0 siblings, 1 reply; 3+ messages in thread
From: Jesus Sandoval @ 2002-12-14 01:23 UTC (permalink / raw)
To: ; +Cc: pgsql-admin
I want to know where to find information about database maintenance as a
developer.
I'm distributing the executable along with the Definition of the database.
After some time, I made changes to the executable and to some tables too.
I have to apply the database changes to the production database and do the
following:
1) Backup the database data, pg_dump is of no use because if the table design
changed then the COPY table FROM stdin produced by pg_dump needs to be
modified to accomodate the space for the new columns.
2) Disable the data integrity checking
3) Drop the table (this drops the Foreign Key constraints)
4) Create the table with the new data layout or definition
5) Insert in the new table the old values (including the new columns or
dropping some columns)
6) Define the data integrity checking
7) Enable the data integrity checking (I'm not sure if this checks the
initial integrity or just start checking with the future inserts and
updates???)
All this is done manually and have to do very detailed analisis and planning
for each change with the customer.
The question is, has somebody faced this kind of problems and found some
automation possibly (even some hints to do scripts about this will be
welcome)
Thanks
Jesus Sandoval
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Database maintenance help
@ 2002-12-14 13:56 David F. Skoll <dfs@roaringpenguin.com>
parent: Jesus Sandoval <meli@mzt.megared.net.mx>
0 siblings, 1 reply; 3+ messages in thread
From: David F. Skoll @ 2002-12-14 13:56 UTC (permalink / raw)
To: jesus@merkatek.com; +Cc: pgsql-admin
On Sat, 14 Dec 2002, Jesus Sandoval wrote:
> following:
> 1) Backup the database data, pg_dump is of no use because if the table design
> changed then the COPY table FROM stdin produced by pg_dump needs to be
> modified to accomodate the space for the new columns.
Actually, you can use pg_dump with some special options. I handle schema
changes like this:
1) Back up the database with a normal pg_dump, just in case.
2) Back it up again with pg_dump "-a -D" -- This produces a bunch of
INSERT INTO... statements
3) Drop the database
4) Recreate the database with the new schema
5) Restore from the dump in step (2). As long as all columns in the old
schema are still present in the new schema, it works. If you need to
get rid of a column, then in step (4), create a database with the unneeded
column, and then do a step (6) whereby you drop unneeded columns.
The only problem is that restoring from (2) is slow; so I use a script to
add a "BEGIN...COMMIT" wrapper around the dump to speed it up.
--
David.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Database maintenance help
@ 2002-12-15 01:14 Jesus Sandoval <meli@mzt.megared.net.mx>
parent: David F. Skoll <dfs@roaringpenguin.com>
0 siblings, 0 replies; 3+ messages in thread
From: Jesus Sandoval @ 2002-12-15 01:14 UTC (permalink / raw)
To: David F. Skoll <dfs@roaringpenguin.com>; +Cc: jesus@merkatek.com; pgsql-admin
"David F. Skoll" escribió:
> On Sat, 14 Dec 2002, Jesus Sandoval wrote:
>
> > following:
> > 1) Backup the database data, pg_dump is of no use because if the table design
> > changed then the COPY table FROM stdin produced by pg_dump needs to be
> > modified to accomodate the space for the new columns.
>
> Actually, you can use pg_dump with some special options. I handle schema
> changes like this:
>
> 1) Back up the database with a normal pg_dump, just in case.
> 2) Back it up again with pg_dump "-a -D" -- This produces a bunch of
> INSERT INTO... statements
> 3) Drop the database
> 4) Recreate the database with the new schema
> 5) Restore from the dump in step (2). As long as all columns in the old
> schema are still present in the new schema, it works. If you need to
> get rid of a column, then in step (4), create a database with the unneeded
> column, and then do a step (6) whereby you drop unneeded columns.
>
> The only problem is that restoring from (2) is slow; so I use a script to
> add a "BEGIN...COMMIT" wrapper around the dump to speed it up.
>
> --
> David.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
Ok, thanks
I had no clue about where to begin with this. I'll try it.
btw, thanks for your contributions to the open source comunity, I'm actually using
the ppp with my ADSL Modem, and found your ssh presentation very interesting, I'm
using it to reach an internal net from a ISP provider (practical magic with ssh).
Jesus Sandoval
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2002-12-15 01:14 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-12-14 01:23 Database maintenance help Jesus Sandoval <meli@mzt.megared.net.mx>
2002-12-14 13:56 ` David F. Skoll <dfs@roaringpenguin.com>
2002-12-15 01:14 ` Jesus Sandoval <meli@mzt.megared.net.mx>
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