oracle如何建立外键,oracle定义外键

oracle创建外键

create TABLE zhao(

网站建设哪家好,找创新互联建站!专注于网页设计、网站建设、微信开发、成都小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了北镇免费建站欢迎大家使用!

id number primary key,

mingcheng nvarchar2(50),

neirong nvarchar2(50),

jiezhiriqi date,

zhuangtai nvarchar2(50)

);

create TABLE tou(

id number primary key,

zhao_id number,

toubiaoqiye nvarchar2(50),

biaoshuneirong nvarchar2(50),

toubiaoriqi date,

baojia number,

zhuangtai nvarchar2(50),

foreign KEY(zhao_id) REFERENCES zhao(id)

);

foreign key (zhao_id) references to zhao(id)

多了个to

oracle怎么创建外键?

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

在oracle数据库中怎样创建主外键关系

主外键需要依托多表来创建,方法如下:

创建主表:

CREATE TABLE SCOTT.DEPT 

(DEPTNO NUMBER(2,0) PARIMARY KEY, 

DNAME VARCHAR2(14), 

LOC VARCHAR2(13));

创建副表及外键:

CREATE TABLE EMP 

(EMPNO NUMBER(4,0) PRIMARY KEY, 

ENAME VARCHAR2(10), 

JOB VARCHAR2(9), 

MGR NUMBER(4,0), 

HIREDATE DATE, 

SAL NUMBER(7,2), 

COMM NUMBER(7,2), 

DEPTNO NUMBER(2,0),

CONSTRAINT FK_DEPTNO FOREIGN KEY (DEPTNO) REFERENCES DEPT (DEPTNO));


网页题目:oracle如何建立外键,oracle定义外键
网页URL:http://myzitong.com/article/dsgpsho.html