View previous topic :: View next topic
|
Author |
Message |
honey
New User
Joined: 15 Sep 2004 Posts: 5 Location: india
|
|
|
|
My tables are look like below. Table1 has 3 Key fields. I want to update the Key2 field values to Key1 (Both are Primary keys for the Table1) in Table1. This will affect the child table(s) Primary key field (Table2.Key1) too (Table2 has only 2 Key fields), because there is no Key field (Table1.Key2). How can I achieve this?
Parent table
Table1
Key1 Key2 Key3
A1 01 0001
A1 02 0002
A2 03 0003
A2 04 0004
A3 05 0005
A4 06 0006
Child Table
Table2
Key1 Key2
A1 0001
A1 0002
A2 0003
A2 0004
A3 0005
A4 0006 |
|
Back to top |
|
|
ayyappareddy
New User
Joined: 17 Aug 2007 Posts: 5 Location: Trivandrum
|
|
|
|
Hi,
The question looks bit confused... Can you be bit clear... |
|
Back to top |
|
|
honey
New User
Joined: 15 Sep 2004 Posts: 5 Location: india
|
|
|
|
Resultant table should be like this
Table1
Key1 Key2 Key3
01 01 0001
02 02 0002
03 03 0003
04 04 0004
05 05 0005
06 06 0006
Child Table
Table2
Key1 Key2
01 0001
02 0002
03 0003
04 0004
05 0005
06 0006 |
|
Back to top |
|
|
hariibm
New User
Joined: 05 Feb 2007 Posts: 61 Location: Chennai
|
|
|
|
Honey,
You can not alter the values of key1 if it is the primary key or part of the primary key. |
|
Back to top |
|
|
honey
New User
Joined: 15 Sep 2004 Posts: 5 Location: india
|
|
|
|
Yes I know but i'd like to know how to unload the table, update the key filed and load it again. |
|
Back to top |
|
|
ayyappareddy
New User
Joined: 17 Aug 2007 Posts: 5 Location: Trivandrum
|
|
|
|
Hi,
Practically speaking this would end in Referential integrity constraint. But, i could give a solution which might work or might not ( i am not sure).
In Table1 you can insert your require fields first,
Table1
Key1 Key2 Key3
A1 01 0001
A1 02 0002
A2 03 0003
01 01 0001
02 02 0002
03 03 0003
then alter the values in the child table
Table2
Key1 Key2
01 0001
02 0002
03 0003
Later delete the inserted values in table 1 and alter the existing values.
This is quite complicated one for huge data (costly).
This is just for Info. |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Honey,
Quote: |
Yes I know but i'd like to know how to unload the table, update the key filed and load it again. |
Speak with your site DBA.
Ayyappa,
Quote: |
Practically speaking this would end in Referential integrity constraint. But, i could give a solution which might work or might not ( i am not sure). |
First you said something. Later contradicted in the very next sentence. |
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
My opinion is this just a bad idea all around. If your really want to update key values you should be deleting the old rec and inserting a new rec. A mass change like that could kill your key pairs depending on the data. |
|
Back to top |
|
|
|