--表创建完成后添加外键
create table distict
(
id number(4) primary key,
name nvarchar2(20) not null
);
create table street
(
id number(4) primary key,
name nvarchar2(50) not null,
district_id number(4)
);
alter table street add constraint distict_fk foreign key (district_id ) references distict (id);
--创建表的同时添加外键
create table distict
(
id number(4) primary key,
name nvarchar2(20) not null
);
create table street
(
id number(4) primary key,
name nvarchar2(50) not null,
district_id number(4),
constraint distict_fk foreign key (district_id ) references distict (id)
);
--在字段属性中添加外键
create table distict
(
id number(4) primary key,
name nvarchar2(20) not null
);
create table street
(
id number(4) primary key,
name nvarchar2(50) not null,
district_id references distict(id)
);