Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2003
    Posts
    7

    Exclamation Unanswered: identity column problem

    Hi,
    I have a table with just one column, an identity column. As I'm used to Oracle, I'm not finding a solution in DB2 to insert a new record in this table, without having to create another column just for that action.

    Any thoughts?
    giazzon

  2. #2
    Join Date
    Jun 2002
    Location
    UK
    Posts
    525
    Are you using the table to generate a key used elsewhere? If so, create a 'sequence' object.

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    interesting problem

    i don't have db2 so i cannot test this, but it seems to me that an extra column wouldn't hurt too much, especially if you allowed it to be null

    insert into identitytable ( nullablecolumn ) values ( null )


    rudy
    http://rudy.ca/

  4. #4
    Join Date
    Jan 2003
    Posts
    7
    Actually this table represents an entity, with no attributes. I didn't know that DB2 has sequence objects, what would make my work easier. But right now I've found a new solution, merging two tables (actually this single column table wasn't necessary at all).
    And Rudy, a new nullable column was in my thoughts as a solution.
    But I'm curious: it's impossible to insert into a table like that?

    Thanks for your support.
    giazzon

  5. #5
    Join Date
    Dec 2002
    Posts
    134

    Re: identity column problem

    Try default, should work

    create table test (id int not null generated always as identity)
    insert into test (id) values (default)

  6. #6
    Join Date
    Jan 2003
    Posts
    7

    Re: identity column problem

    Originally posted by chuzhoi
    Try default, should work
    And it did!
    giazzon

Posting Permissions

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