日期:2014-05-16  浏览次数:20560 次

创建外键的方法
方法一:
create table OrderMaster
(
  OrderID number primary key,
  UserName varchar2(20),
  OrderDate date
)

create table OrderDetail
(
  OrderID number,
  PName varchar2(20),
  Count number,
  constraint FK_OrderID foreign key(OrderID) references OrderMaster(OrderID)
)


方法二:

create table OrderDetail
(
  OrderID number,
  PName varchar2(20),
  Count number
)

alter table OrderDetail
add constraint FK_OrderID foreign key (OrderID) references OrderMaster(OrderID)