Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2002
    Posts
    25

    Wink Unanswered: 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!!!

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

  3. #3
    Join Date
    Dec 2002
    Posts
    25

    Question to change to the generation

    since I do so that column IDMOTIVE has property GENERATED ALWAYS IDENTITY?

  4. #4
    Join Date
    May 2002
    Location
    General Deheza, Cba, Arg.
    Posts
    276

    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');

  5. #5
    Join Date
    Nov 2003
    Posts
    14
    you can do like this

    values for nextvalue ....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •