Solved

AUTO NUMBER

Posted on 2006-06-19
2
409 Views
Last Modified: 2012-08-13
Is there anyway I can create auto-number columns in DB2, Like we do in access
0
Comment
Question by:claracruz
2 Comments
 
LVL 45

Accepted Solution

by:
Kent Olsen earned 250 total points
ID: 16935633
Sure.  :)

In DB2 they're call "identity" columns.  Nothing more than an integer that increments (usually by 1) every time a row is inserted.  The column can be defined so that the insert must accept the value generated by DB2, or have DB2 generate a value only when a value isn't stored.


CREATE TABLE any
(
  AutoColumn integer not null identity;
...
);


Good Luck,
Kent
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 16935968
also see SEQUENCE

which version / edition  / OS are you using DB2/UDB with?
 
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to use a CTE in a DB2 user defined function 6 114
CATALOG A DB2 TCPIP NODE with AN ALIAS 2 143
RPG Free Prototypes using  *LDA data 5 219
finding tables 2 58
November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question