oracle怎么创建外键?

oracle怎么创建外键?,第1张

create TABLE zhao(\x0d\x0a id number primary key,\x0d\x0a mingcheng nvarchar2(50),\x0d\x0a neirong nvarchar2(50),\x0d\x0a jiezhiriqi date,\x0d\x0a zhuangtai nvarchar2(50)\x0d\x0a)\x0d\x0acreate TABLE tou(\x0d\x0a id number primary key,\x0d\x0a zhao_id number,\x0d\x0a toubiaoqiye nvarchar2(50),\x0d\x0a biaoshuneirong nvarchar2(50),\x0d\x0a toubiaoriqi date,\x0d\x0a baojia number,\x0d\x0a zhuangtai nvarchar2(50),\x0d\x0a foreign KEY(zhao_id) REFERENCES zhao(id)\x0d\x0a)\x0d\x0aforeign key (zhao_id) references to zhao(id)\x0d\x0a多了个to

create table T (

A NUMBER(14)not null,

B VARCHAR2(11) not null,

C VARCHAR2(20) not null,

D VARCHAR2(60),

E VARCHAR2(20) not null,

F VARCHAR2(50) not null,

constraint pk$T primary key (A), -- 主键

constraint uk$T unique (B) -- 唯一键

)

create table U (

UA NUMBER(14)not null,

UB VARCHAR2(11) not null,

UC VARCHAR2(20) not null,

UD VARCHAR2(60),

UE VARCHAR2(20) not null,

UF VARCHAR2(50) not null,

constraint fk$U_UA foreign key (UA) references T(A)-- 外键 fk$U_UA 是外键名

)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11918073.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存