Oracle: add a foreign key 

Joined:
04/09/2007
Posts:
565

February 18, 2010 21:17:34
-- add a foreign key to abother table
alter table BOOKS
  add constraint BK_ATHR_FK foreign key (AUTHOR_ID)
  references AUTHORS (AUTHOR_ID);

-- add a foreign key to same table
-- PARENT_MENU_ID is a foreign key to primary key MENU_ID
alter table MENUS
  add constraint MENU_MENU_FK foreign key (PARENT_MENU_ID)
  references MENUS (MENU_ID);
[ Comment  | Tags ]
 
Easy email testing with http://www.ximailstop.com