Subject Re: [ib-support] How to add a foreign key after creating a table
Author Martijn Tonies
Hi,

Reading the documentation tells me the exact syntax is:

ALTER TABLE TABLE2
ADD CONSTRAINT cons_name FOREIGN KEY FKEY1 REFRENCES tablename

(other_col [,other_col] ) [ON DELETE {cascade option}] [ON UPDATE {cascade
option}]


With regards,

Martijn Tonies
InterBase Workbench - the developer tool for InterBase
http://www.upscene.com

Firebird Workbench - the developer tool for Firebird
http://www.upscene.com

Upscene Productions
http://www.upscene.com

"This is an object-oriented system.
If we change anything, the users object."

> 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?