Hi Gerd,
I am on DB2 11.5.9 and think there is a bug in the "create table
script" generator for foreign keys when aliases are involved.
Example:
----------------------------------------
DROP TABLE IF EXISTS X.TBL1
;
DROP TABLE IF EXISTS X.TBL2
;
CREATE TABLE X.TBL1
(
OB_OID bigint PRIMARY KEY NOT NULL,
BLA bigint
)
;
CREATE TABLE X.TBL2
(
OB_OID bigint PRIMARY KEY NOT NULL,
BLUB bigint
)
;
ALTER TABLE X.TBL2
ADD CONSTRAINT CONS_TEST
FOREIGN KEY (BLUB)
REFERENCES X.TBL1(OB_OID)
;
CREATE OR REPLACE ALIAS Y.TBL1 FOR X.TBL1
;
----------------------------------------
When I do a generate on Tables TBL1 and TBL2 in Schema X (right click
-> Scripts -> Create Table Script in Sql editor) from the object tree
I get this result:
----------------------------------------
CREATE TABLE X.TBL1
(
OB_OID bigint PRIMARY KEY NOT NULL,
BLA bigint
)
;
CREATE TABLE X.TBL2
(
OB_OID bigint PRIMARY KEY NOT NULL,
BLUB bigint
)
;
ALTER TABLE X.TBL2
ADD CONSTRAINT CONS_TEST
FOREIGN KEY (BLUB)
REFERENCES X.TBL1(OB_OID)
;
ALTER TABLE X.TBL2
ADD CONSTRAINT CONS_TEST
FOREIGN KEY (BLUB)
REFERENCES Y.TBL1(OB_OID)
;
----------------------------------------
Another question:
Is it possible to build in more options for the generator?
Like
1.) DROP TABLE IF EXISTS instead of DROP TABLE
2.) push out more information, e.g. table spaces, index spaces,
compression for tables or
ALLOW REVERSE SCANS, PAGE SPLIT SYMMETRIC for indexes,...
Thanks :-)
Robert
|