Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 1532|回复: 0
打印 上一主题 下一主题

誰會Oracle 10G 的請進來help我

[复制链接]

0

主题

1

好友

29

积分

初级会员

Rank: 1

跳转到指定楼层
1#
发表于 2009-3-8 10:34 PM |只看该作者 |倒序浏览
學校給我一道有關於database programming的問題, 但是我想了很久還是想不通! 下面的圖片有問題和我自己的答案, 有誰可以為我改正嗎?

Question:--Produce a revised script for the drop table and create table stages with primary and foreign key constraints. This may be called solutionswk3tables.sql.

Answer:--這是我的answer
drop table patient;
drop table doctor;
drop table visits;
drop table vaccinations;
drop table valid_for;


create table patient
( pid char(6) not null,
pname char(20) not null,
address varchar2(100) not null,
dobirth date not null,
date_reg date not null,
constraint patient_pid_pk primary key (pid));

create table doctor
( did char(1) not null,
dname char(20) not null,
date_start date not null,
constraint doctor_did_pk primary key (did));

create table valid_for
( vaccinated char(20) not null,
lasting_years number not null,
constraint valid_for_vaccinated_pk primary key (vaccinated));

create table visits
( pid char(6) not null,
did char(1) not null,
vdate date not null,
constraint visits_pid_fk foreign key (pid) references patient(pid),
constraint visits_did_fk foreign key (did) references doctor(did),
constraint visits_vdate_pk primary key (vdate));

create table vaccinations
( pid char(6) not null,
vdate date not null,
action number not null,
vaccinated char(20) not null,
constraint vaccinations_pid_fk foreign key (pid) references patient(pid),
constraint vaccinations_vaccinated_fk foreign key (vaccinated) references valid_for(vaccinated),
constraint vaccinations_vdate_fk foreign key (vdate) references visits(vdate));

然後,下一道問題問倒我了

question:--
Run the script provided of dataloadwk3errors.sql and check that all data items in it are rejected on primary key or foreign key rule violations.

dataloadwk3errors.sql file裡面的東西:--/* These below should be rejected */

insert into patient values('3','Rachel','Tynemouth','14-feb-1982','31-jan-1990');
insert into doctor values ('1','Michael Smith','25-jul-1997');
insert into visits values('4','1','26-jun-2000');
insert into vaccinations values('4','30-jun-2000',1,'cholera');
insert into vaccinations values('4','30-jun-2006',2,'typhoid');
insert into valid_for values('cholera',0.5);

insert into visits values('2','5','17-dec-2004');
insert into visits values('19','2','16-dec-2004');
insert into vaccinations values('17','27-jul-2002',1,'typhoid');
insert into vaccinations values('2','28-jul-2002',1,'typhoid');

/* end of script */

只要你的script可以blocked or rejected 所有在dataloadwk3errors.sql 的data, 那就對了....我的script blocked不到全部只有2 rows created而已
有誰可以blocked它們全部?




收藏收藏0
您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2024-10-25 07:24 AM , Processed in 0.095799 second(s), 26 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部