IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Identity Column


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Nov 04, 2010 11:56 am
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Nov 04, 2010 12:17 pm
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
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: 1281
Location: Belgium

PostPosted: Thu Nov 04, 2010 3:21 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts How to load to DB2 with column level ... DB2 6
No new posts RC query -Time column CA Products 3
No new posts first column truncated in search result IBM Tools 13
No new posts Split a record with data in a differe... DFSORT/ICETOOL 8
Search our Forums:

Back to Top