Suresh Paldia
Can You FK(Foreign Key) reference a table with no primary key?
By Suresh Paldia in SQL on Nov 01 2010
  • Pankaj  Kumar Choudhary
    May, 2015 21

    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, )

    • 2
  • Mukesh Kumar
    Aug, 2017 23

    by the use of unique key not null

    • 0
  • Rahul Prajapat
    May, 2015 30

    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, )

    • 0
  • Abrar Ahmad Ansari
    Mar, 2015 10

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

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS