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

    Exclamation Unanswered: Tables With Column Identity

    I have two related tables, each one of them has defined like primary key to a column type integer.

    INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1, CACHE 10)

    The problem is that I want to export all the data towards a structure of similar tables, but conserving the referential integrity, that is to say, with such data.

    thanks....

  2. #2
    Join Date
    Apr 2003
    Posts
    191

    Re: Tables With Column Identity

    Hi,

    I believe you have no problems with DB2 export, but may have problems with DB2 import.

    The point about IDENTITY columns is just that - you can't insert into them. If you are able to tweak the table design at the target database a bit you can try to import into tables with GENERATED BY DEFAULT (or something, you will find out) column types. This should leave given references alone.

    Some people strongly argue against using IDENTITY columns because you can't do SQL operations on such columns.

    Johann

    Originally posted by zarconja
    I have two related tables, each one of them has defined like primary key to a column type integer.

    INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1, CACHE 10)

    The problem is that I want to export all the data towards a structure of similar tables, but conserving the referential integrity, that is to say, with such data.

    thanks....

  3. #3
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: Tables With Column Identity

    In the IMPORT Command, MODIFIED BY options, there are a couple of them .. IDENTITYIGNORE etc

    Check the command reference for more info


    Cheers

    Sathyaram

    Originally posted by jsander
    Hi,

    I believe you have no problems with DB2 export, but may have problems with DB2 import.

    The point about IDENTITY columns is just that - you can't insert into them. If you are able to tweak the table design at the target database a bit you can try to import into tables with GENERATED BY DEFAULT (or something, you will find out) column types. This should leave given references alone.

    Some people strongly argue against using IDENTITY columns because you can't do SQL operations on such columns.

    Johann
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  4. #4
    Join Date
    Dec 2003
    Posts
    1

    Re: Tables With Column Identity

    If the source column is GENERATED ALWAYS AS IDENTITY, define the target column as INTEGER NOT NULL PRIMARY KEY when you create the target table.

    Perform export and load/import. You should get exactly the same integer numbers in the target primary key column as in the source column. I tried it yesterday and it works. I used Load instead of import, though, to make it faster.

    Hope this helps.


    Originally posted by zarconja
    I have two related tables, each one of them has defined like primary key to a column type integer.

    INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1, CACHE 10)

    The problem is that I want to export all the data towards a structure of similar tables, but conserving the referential integrity, that is to say, with such data.

    thanks....

Posting Permissions

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