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 > generated always identity

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-04-03, 11:04
zarconja zarconja is offline
Registered User
 
Join Date: Dec 2002
Posts: 25
Wink generated always identity

I have created a table of the following way:

CREATE TABLE MOTIVE (
IDMOTIVE INTEGER NOT NULL GENERATED DEFAULT AS IDENTITY ( START WITH +1 , INCREMENT BY +1 , CACHE 2 , ORDER ) ,
DESCRIPTION VARCHAR(100) );

Soon I make the load of data with:

INSERT INTO MOTIVE VALUES
(1,'DES 1'),
(2,'DES 2'),
(5,'DES 5'),
(6,'DES 6');

Soon I need that column IDMOTIVE has the property of GENERATED ALWAYS IDENTITY, and can make the load of data with:

INSERT INTO MOTIVE (DESCRIPTION) VALUES
('DES'),
('DESCR');

and consequently the column ID generates ID respective 7 and 8.

Since I can do this?

Thanks!!!
Reply With Quote
  #2 (permalink)  
Old 12-04-03, 12:03
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Sorry, I don't understand the question.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 12-05-03, 14:49
zarconja zarconja is offline
Registered User
 
Join Date: Dec 2002
Posts: 25
Question to change to the generation

since I do so that column IDMOTIVE has property GENERATED ALWAYS IDENTITY?
Reply With Quote
  #4 (permalink)  
Old 12-07-03, 16:30
achiola achiola is offline
Registered User
 
Join Date: May 2002
Location: General Deheza, Cba, Arg.
Posts: 273
Re: to change to the generation

Hi zarconja

If you use the "GENERATED ALWAYS IDENTITY", do you not insert data in identity col, but, if you use the "GENERATED DEFAULT AS IDENTITY" you can insert a value in the indentity col or not.

In booth case the identity col make the ID col.

If you use the "GENERATED DEFAULT AS IDENTITY": A and B is valid.
A.-----------------------------------
INSERT INTO MOTIVE VALUES
(1,'DES 1'),
(2,'DES 2'),
(5,'DES 5'),
(6,'DES 6');
B.-----------------------------------
INSERT INTO MOTIVE (DESCRIPTION) VALUES
('DES'),
('DESCR');
Reply With Quote
  #5 (permalink)  
Old 12-08-03, 00:56
richardluopeng richardluopeng is offline
Registered User
 
Join Date: Nov 2003
Posts: 14
you can do like this

values for nextvalue ....
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