By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,302 Members | 1,163 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,302 IT Pros & Developers. It's quick & easy.

Update of foreign key values

P: n/a
I have two tables in two databases (Pg 7.2.1 - yes I need to upgrade but
there are several other dependencies I have to resolve first) and I need
to update one database's tables so they can be merged into the other
database's table. I know I can drop the constraints and update the tables
(primary key, and foreign key) but was hoping I'd not have to do that.
An attempt at using the techniques in Joel Burton's "Referential
Integrity Tutorial & Hacking the Referential Integrity tables" was
unsuccessful.

Is there a method I can use to add 1000 to all the primary and foreign
keys in one pass? Searches using Google and the PostgreSQL docs turned up
nothing useful to my situation. I see if the table/constraint would have
been created differently the updates would have cascaded but that did
not happen.
TIA,
Rod
--
"Open Source Software - Sometimes you get more than you paid for..."

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 11 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Roderick A. Anderson wrote:
I have two tables in two databases (Pg 7.2.1 - yes I need to upgrade but
there are several other dependencies I have to resolve first) and I need
to update one database's tables so they can be merged into the other
database's table. I know I can drop the constraints and update the tables
(primary key, and foreign key) but was hoping I'd not have to do that.
An attempt at using the techniques in Joel Burton's "Referential
Integrity Tutorial & Hacking the Referential Integrity tables" was
unsuccessful.

Is there a method I can use to add 1000 to all the primary and foreign
keys in one pass? Searches using Google and the PostgreSQL docs turned up
nothing useful to my situation. I see if the table/constraint would have
been created differently the updates would have cascaded but that did
not happen.


Strikes me as a perfect example for having the constraint defined "ON
UPDATE CASCADE". Or making it "DEFERRABLE" and do both changes in a
transaction after setting the constraint deferred.
Jan

--
#================================================= =====================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================= = Ja******@Yahoo.com #
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 11 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.