Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Identity Column

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

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Thu Nov 04, 2010 11:11 am    Post subject: Identity Column
Reply with quote

I have a requirement where a particular column needs to have a sequence number generated for each row inserted.

I am planning to use the IDENTITY COLUMN to automatically generate the sequence.

My doubt is , what happens when a particular row is deletd and a new row is inserted ?

Ex :

Identity_Column data1 data2
1 XX1 yyya
2 XX2 yyyb
3 XX3 yyyc
4 XX4 yyyd

If i delete the row 3 will the Sequence number of xx4 yyyd still remain as 4 or will it be decrementd to 3?

Also if sequence 4 is not going to be decremened , now if i try to insert a new row will it take a sequence id 5 ? or will it take the sequence id 3 as its no longer available ?


Do let me know if am not expressing myself clearly

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

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10211
Location: italy

PostPosted: Thu Nov 04, 2010 11:56 am    Post subject: Reply to: Identity Column
Reply with quote

why not test it Yourself ???
a couple of spufi statements will solve Your doubt icon_biggrin.gif
Back to top
View user's profile Send private message
cvishu

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Thu Nov 04, 2010 12:03 pm    Post subject:
Reply with quote

Err the problem is we dont have access to CREATE a table .. and as of now i dont find any existing tables tat have the IDENTITY Column .. so basically am helpless.

I need to go through lot of DBA approvals to get a table created.. and for testing am damn sure those DBA wont let me create a table icon_smile.gif

Thanks
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10211
Location: italy

PostPosted: Thu Nov 04, 2010 12:17 pm    Post subject: Reply to: Identity Column
Reply with quote

Quote:
I am planning to use the IDENTITY COLUMN to automatically generate the sequence.

table design has alway ( or at least should ) been/be an application development/DBA support joint task

why worry by Yourself ? icon_biggrin.gif

if You have the authority to do the table design ,
it is strange that You do not have the authority to do a bit of prototyping by Yourself

what I mean is that everybody should be given access to the tools necessary for his work
Back to top
View user's profile Send private message
cvishu

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Thu Nov 04, 2010 12:34 pm    Post subject:
Reply with quote

yup but sadly i am only allowed to propose the design .... icon_sad.gif
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Thu Nov 04, 2010 3:21 pm    Post subject:
Reply with quote

"Identity-column or not" is not part of the logical model. It's technical.

But to answer your questions :
1) No, other rows are unaffected by delete of a row.
2) identity columns keep incrementing (normally by 1) but one can specify other increments (even -1), one can also cycle after maximum is reached , but then you might get duplicates.
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:

Similar Topics
Topic Author Forum Replies Posted
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
No new posts Add system date inside of a PS file a... pramitdas DFSORT/ICETOOL 5 Sun Aug 28, 2016 12:06 am
No new posts Converting NULL column into NOT NULL ... Raghu navaikulam DB2 5 Sat Aug 06, 2016 3:45 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us