If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Identity columns

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-17-04, 04:53
Tank Tank is offline
Registered User
 
Join Date: Feb 2004
Location: Copenhagen
Posts: 220
Question Identity columns

Theres been a lot of talk about:
'slapping on identity columns'

Very well, now I slapped an integer column
on my table. How do i fill it up with consecutive
numbers using sql?

(I'd rather not move all data to a new table
with a generated column, and you can't set
the column to autogeneration if you slap it on
after table creation)

Cheers
__________________
Kristian K. Hansen
Project Supervisor
National Board of Health
Reply With Quote
  #2 (permalink)  
Old 08-18-04, 01:52
fadace fadace is offline
Registered User
 
Join Date: Nov 2002
Location: Switzerland
Posts: 523
Code:
ALTER TABLE YourTbl 
ADD COLUMN YOURNR INTEGER 
GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1 );
__________________
F. Celaia
DBA Sybase/DB2/Oracle/MS-SQL
Reply With Quote
  #3 (permalink)  
Old 08-18-04, 04:13
Tank Tank is offline
Registered User
 
Join Date: Feb 2004
Location: Copenhagen
Posts: 220
Exclamation No fillup on existing table

I'm afraid that doesn't
work on existing tables
__________________
Kristian K. Hansen
Project Supervisor
National Board of Health
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On