4
Reply

Can You FK(Foreign Key) reference a table with no primary key?

Suresh Paldia

Suresh Paldia

Nov 01, 2010
4.8k
0

    It we can create a FK reference a table with no primary key if column is Unique Exa: Create Table My_Tab2 ( id int unique, nam int )Create Table My_Tab3 ( iid int constraint Mycons references My_tab2(id), namo int not null, )

    by the use of unique key not null

    Mukesh Kumar
    August 23, 2017
    0

    Yes we can create a FK reference a table with no primary key if column is Unique Exa: Create Table My_Tab2 ( id int unique, nam int )Create Table My_Tab3 ( iid int constraint Mycons references My_tab2(id), namo int not null, )

    Rahul Prajapat
    May 30, 2015
    0

    yes you can but column must be unique key has created. see below create table Test1 (ID int unique );CREATE TABLE IR.test2 (Test2_Id int, FOREIGN KEY (Test2_Id) REFERENCES IR.test1(ID) )

    Abrar Ahmad Ansari
    March 10, 2015
    0