Declaring a Foreign Key
SQL>
SQL>
SQL> CREATE TABLE myTable (myTableID INT PRIMARY KEY NOT NULL,
2 Name VARCHAR(50));
Table created.
SQL>
SQL> CREATE TABLE Phone (
2 PhoneID INT PRIMARY KEY NOT NULL,
3 myTableID INT,
4 PhoneNo VARCHAR(20),
5 CONSTRAINT FID_FK FOREIGN KEY(myTableID)
6 REFERENCES myTable(myTableID));
Table created.
Related examples in the same category