十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
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
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 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));