问一道低级的题目,知道的说一下 14. 下面关于外关键字描述不正确的是A.外关键字必须是所参考表的主关键字. B.外关键字属性值这可以为空C.定义外关键字需要对所参考表拥有select权D.一个表中可以有多个外关键字.题目为单选题,高手指教 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 C.定义外关键字需要对所参考表拥有select权================================需要reference权限,而不是select权限 A是肯定不对,B,D我觉得都对,C不知道了 呀 答案是C原因如下:A外键必须是其他表的主键B 不设置外键可以为空(因为不再是以前表的主键)D 一张表可以有多个外键C 是不正确的 应该有References权限看下SQL 标准DELETE INSERT SELECT UPDATE .其中SELECT权限对应READ权限,SQL还包括References权限,用来限制创建关系时定义外码的能力。Eg:--零件表create table p(pno char(4) not null,pname char(20) not null,color char(8),weight smallint,price smallint,primary key (pno));create table s(sno char(4) not null,sname char(20) not null,status char(10),saddr char(20),man char(10),dt date,tel char(16),primary key (sno));create table j(jno char(4) NOT NULL, jname char(20), jcity char(20), balance number(7,2), primary key(jno)); create table spj(sno char(4) not null,pno char(4) not null,jno char(4) not null,price numeric(7,2),qty smallint,primary key (sno,pno,jno),foreign key(sno) references s(sno),foreign key(pno) references p(pno),foreign key(jno) references j(jno),check(qty between 0 and 10000)); 子表外键在父表中的对应字段也可以不是主键吧?SQL> create table test4(aaa number primary key, 2 bbb number unique);表已创建。SQL> create table test5(bbb number references test4(bbb));ora_sysevent is CREATE表已创建。 你的说法是正确的~~我做过测试 没有想到的是 unique关键字所以create table test5(bbb number, foreign key(bbb) references test4(bbb)); 是可以的 在此更正~~ oracle新手问题 建表的时候,如何指定表所在的表空间? oracle sql how to write? 有存储过程经验请进~~可以迭代否? 怎样从数据库中跨网传递一个简单的windows消息? 关于触发器 存储成能返回字符型的值吗? 启动问题? 请帮助——执行字符串的函数 ☆☆★★Oracle PL/SQL 查询NULL字段的不解★★☆☆ SUBSTR问题 触发器 创建表的问题
================================
需要reference权限,而不是select权限
原因如下:
A外键必须是其他表的主键
B 不设置外键可以为空(因为不再是以前表的主键)
D 一张表可以有多个外键
C 是不正确的 应该有References权限看下SQL 标准DELETE INSERT SELECT UPDATE .其中SELECT权限对应READ权限,SQL还包括References权限,用来限制创建关系时定义外码的能力。Eg:
--零件表create table p
(pno char(4) not null,
pname char(20) not null,
color char(8),
weight smallint,
price smallint,
primary key (pno));create table s
(sno char(4) not null,
sname char(20) not null,
status char(10),
saddr char(20),
man char(10),
dt date,
tel char(16),
primary key (sno));create table j
(jno char(4) NOT NULL,
jname char(20),
jcity char(20),
balance number(7,2),
primary key(jno));
create table spj
(sno char(4) not null,
pno char(4) not null,
jno char(4) not null,
price numeric(7,2),
qty smallint,
primary key (sno,pno,jno),
foreign key(sno) references s(sno),
foreign key(pno) references p(pno),
foreign key(jno) references j(jno),
check(qty between 0 and 10000));
SQL> create table test4(aaa number primary key,
2 bbb number unique);表已创建。SQL> create table test5(bbb number references test4(bbb));
ora_sysevent is CREATE表已创建。
我做过测试
没有想到的是 unique关键字
所以
create table test5(bbb number,
foreign key(bbb) references test4(bbb));
是可以的 在此更正~~