473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Update of foreign key values

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
1 2576
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Fraser Hanson | last post by:
Hello, I have a table which has a foreign key relationship with itself. I want and expect my updates to cascade (deletes definitely cascade as expected) but instead I just get error 1217:...
0
by: john | last post by:
Hi, I'm using: - Red Hat 9 - MySQL 3.23.56 create table t1( id integer not null, primary key(id)) type = INNODB;
2
by: Gunnar Vøyenli | last post by:
Hi! For the sake of simplicity, I have three tables, Employee, Department and Work Employee >---- Department \ / \ / ^ ^ Work
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
7
by: robert | last post by:
i need to update a column which is a member of the PK on this table. there are some thousands of rows to be updated, many more thousand already in the table. so, i get a constraint violation...
7
by: PC Datasheet | last post by:
Looking for suggestions ---- A database was designed for a national automobile inspection program. In it's simplest form, the database has two tables: TblOwner OwnerID <Year/Make/Model owned...
0
by: M. David Johnson | last post by:
I cannot get my OleDbDataAdapter to update my database table from my local dataset table. The Knowledge Base doesn't seem to help - see item 10 below. I have a Microsoft Access 2000 database...
3
by: dbuchanan | last post by:
Hello, (Windows forms - SQL Server) I fill my datagrid with a stored procedure that includes relationships to lookup tables so that users can see the values of the combobox selections rather...
1
by: Grant McLean | last post by:
Hi First a simple question ... I have a table "access_log" that has foreign keys "app_id" and "app_user_id" that reference the "application_type" and "app_user" tables. When I insert into...
0
by: David Linsin | last post by:
I created a simple test case to reproduce the problem (also check Bug #15500): import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.