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 > Tables With Column Identity

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-19-03, 09:37
zarconja zarconja is offline
Registered User
 
Join Date: Dec 2002
Posts: 25
Exclamation 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....
Reply With Quote
  #2 (permalink)  
Old 11-19-03, 11:29
jsander jsander is offline
Registered User
 
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

Quote:
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....
Reply With Quote
  #3 (permalink)  
Old 11-19-03, 11:50
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
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

Quote:
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.
Reply With Quote
  #4 (permalink)  
Old 12-08-03, 15:44
MTA MTA is offline
Registered User
 
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.


Quote:
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....
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