answersLogoWhite

0


Best Answer

-- two dashes mean a comment in DB2 for VM and z/OS

-- 1st design your table - considered optional

-- 2nd declare your table - maditory. You still can not alter a table that

-- does not exist

-- 3rd alter the table to add the foreign key

-- DB2 for FOREIGN KEY

ALTER TABLE owner.Tablename

ADD CONSTRAINT name FOREIGN KEY (column name(s) )

REFERENCES REDBA.RESF_FINAL_CARD (column name(s) )

ON DELETE RESTRICT -- means stop them

or

ON DELETE cascade -- Cascade means to delete everthing here

or

ON DELETE SET value -- update the value of the column

;

-- note since you are doing DDL not dml the commit is implicit!! so

-- there is no COMMIT WORK needed

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you declare foreign key in db2?
Write your answer...
Submit
Still have questions?
magnify glass
imp