Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
how many of you tried this?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
meetsrk

New User


Joined: 13 Jun 2004
Posts: 85

PostPosted: Thu Jun 17, 2004 11:55 am    Post subject: how many of you tried this?
Reply with quote

hi ppl,

can we change the value of primary key in DB2?

if not, then you are in for a suprise
if yes, then tell me why is that happening?

i.e in a table of emp,
consider, empno - integer, not null and primary key
ename - char(20)
esal - decimal(7,2)

i can write a sql statment like,
Code:

update emp set empno = empno + 1

the above statment did execute succesfully and incremented all the values of empno by 1.
pls try and tell me.
[/img]
Back to top
View user's profile Send private message

rick

New User


Joined: 18 Jun 2004
Posts: 59
Location: Chennai

PostPosted: Fri Jun 18, 2004 3:56 pm    Post subject:
Reply with quote

Hi,

Primary key values can be changed. But the new value should no be already existing one.
Back to top
View user's profile Send private message
unna

New User


Joined: 15 Oct 2004
Posts: 17

PostPosted: Fri Oct 15, 2004 3:43 pm    Post subject:
Reply with quote

Hi ,
Primary key can be changed by using Alter Table command and not by Update .

Try with Alter table command and let me know. icon_smile.gif as i haven't tried on it.

Thanks,
Back to top
View user's profile Send private message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Thu Dec 09, 2004 2:49 pm    Post subject: Try This...
Reply with quote

Hi,

We can directly change primary key values using update. But it will give an error if a foreign key is created refering to this primary key. Ok U may got it.

Eg: EMP (EMPNO,ENAME,JOB,DETPTNO) DEPTNO is Foreign Key
DEPT(DEPTNO,DNAME,LOC) DEPTNO is primary key

In this situation if u try to change DEPTNO of DEPT u will get an error.


Bye,
Reddy
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:


Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us