www.syrq.net > orAClE创建表外键怎么写

orAClE创建表外键怎么写

oracle创建外键约束有两种方法: 1、创建表时直接创建外键约束 create table books( bookid number(10) not null primary key, bookName varchar2(20) not null, price number(10,2), categoryId number(10) not null references Category(id) -...

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), biaoshune...

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), biaoshune...

alter table score add constraint FK_DEPTNO foreign key (学号) references courses(课程名);

select * from user_constraints cc where cc.r_constraint_name in ( select c.r_constraint_name from user_constraints c where c.constraint_type = 'R' and c.constraint_name = '??' ) ?? 是你外键的名字;spiderrobot 的方法也不错,但是...

主外键需要依托多表来创建,方法如下: 创建主表: 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...

有时候删除某张表记录的时候,会报错外键约束不能删除。 如果不了解表之间的关系,可以通过以下语句查询到外键是建在哪张表上的: select * from dba_constraints where constraint_name='xxx' and constraint_type = 'R'; 例如:我的程序日志中...

查找表的外键(包括名称,引用表的表名和对应的键名,下面是分成多步查询): select * from user_constraints c where c.constraint_type = 'R' and c.table_name = 要查询的表 查询外键约束的列名: select * from user_cons_columns cl where...

3 stuid number(10) references t_stu(stuid) 就是这个字段关联t_stu表的stuid字段; 4 couseid number(10), 5 constraint fk_couseid foreign key(couseid) 6 references t_couse(couseid) 7 on delete cascade); 这个是外键关联,并做同步删除...

网站地图

All rights reserved Powered by www.syrq.net

copyright ©right 2010-2021。
www.syrq.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com