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
 
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: 10309
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: 10309
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: 1281
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 column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 19 Thu Jul 13, 2017 2:11 pm
This topic is locked: you cannot edit posts or make replies. DB2 query Using Recursion, Converting... smilewithashu2 DB2 3 Tue Jan 03, 2017 12:50 pm

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