Subject How to add a foreign key after creating a table
Author Sujan Sreenath
Hi everybody,

Suppose there are two tables.

CREATE TABLE TABLE1 (PKEY1 INTEGER NOT NULL PRIMARY KEY)

CREATE TABLE TABLE2 (FKEY1 INTEGER NOT NULL)

after running this SQL i want to add a foreign key contraint to FKEY1 on TABLE2, i tried the following

ALTER TABLE TABLE2
ADD CONSTRAINT cons_name FOREIGN KEY FKEY1 REFRENCES TABLE1.PKEY1

but this does not work, any suggestions?