问题描述
任何人都可以说出为什么这个剧本不起作用?
Anybody can tell why this script isn't working?
DROP SEQUENCE seqClient;
DROP SEQUENCE seqPrescription;
DROP SEQUENCE seqMedicament;
DROP SEQUENCE seqMedecin;
DROP SEQUENCE seqRenou;
$
ALTER TABLE RX_prescription DROP CONSTRAINT RX_prescription_NoCli_fk;
ALTER TABLE RX_RENOUVELLEMENT DROP CONSTRAINT RX_renouvellement_NoPres_fk;
PROMPT销毁des tables
DROP TABLE RX_client;
DROP TABLE RX_renouvellement;
DROP TABLE RX_medicament;
DROP TABLE RX_docteur;
DROP TABLE RX_prescription;
PROMPTCréationdescéquences
CREATE SEQUENCE seqClient START with 20;
CREATE SEQUENCE seqPrescription以20开始;
创建序列seqMedicament以20开始;
创建序列seqMedecin START with 20;
创建序列seqRenou以20开始;
PROMPT C réationdela table RX_client - 提示la ligne dans控制台
CREATE TABLE RX_client(
不, NUMBER(6),
Prenom VARCHAR2(20)CONSTRAINT client_prenom_nn NOT NULL,
Nom VARCHAR2(15)CONSTRAINT client_nom_nn NOT NULL,
Rue VARCHAR2(30),
Ville VARCHAR2(12)DEFAULT'Montréal',
电话 CHAR(10),
CONSTRAINT RX_client_No_pk PRIMARY KEY(No));
$
PROMPTCréationdela table RX_medicament
CREATE TABLE RX_medicament(
否 NUMBER(5),
Nom CHAR(25),
Prix NUMBER(7,2) ,$
CONSTRAINT RX_medicament_No_pk PRIMARY KEY(No));
$
PROMPTCréationdela table RX_docteur
CREATE TABLE RX_docteur(
No NUMBER(5),
Prenom VARCHAR2(20),
Nom VARCHAR2(25),
Rue VARCHAR2(30),
Ville VARCHAR2(20)DEFAULT'Montréal',
电话 CHAR(10),
CONSTRAINT RX_docteur_No_pk PRIMARY KEY(No));
PROMPT Créationdela table RX_prescription
CREATE TABLE RX_prescription(
No NUMBER(6),
DatePres 日期,
NoMedi NUMBER(5),
Quantite NUMBER(4),
NbRenou NUMBER(2),
NoCli NUMBER(6),
NoDoc NUMBER(6),
约束RX_NbRenou_ck检查(NbRenou IN(0,1,2,3,4,5,6,7,8,9,10)),
CONSTRAINT RX_Quantite_ck CHECK(Quantite< = 100),
CONSTRAINT RX_prescription_No_pk PRIMARY KEY(No));
$
INSERT INTO RX_prescription VALUES(1,TO_DATE('01072001','DDMMYYYY'),1,50,3,1 ,4);
$
INSERT INTO RX_prescription VALUES(2,TO_DATE('15072001','DDMMYYYY'),1,25,4,2,5);
INSERT INTO RX_prescription VALUES(3,TO_DATE('22072001','DDMMYYYY'),2,40,5,3,6);
$
INSERT INTO RX_prescription VALUES(4,TO_DATE('28072001',' DDMMYYYY'),2,50,3,4,7);
$
插入到RX_prescription值(5,TO_DATE('01082001','DDMMYYYY'),3,20,4,5,8 ); $
INSERT INTO RX_prescription VALUES(6,TO_DATE('12082001','DDMMYYYY'),3,30,5,6,9);
$
INSERT INTO RX_prescription VALUES(7,TO_DATE('15082001','DDMMYYYY'),4,50,6,7,1);
$
INSERT INTO RX_prescription VALUES(8,TO_DATE('17082001','DDMMYYYY') ),4,40,1,8,2);
$
INSERT INTO RX_prescription VALUES(9,TO_DATE('22082001','DDMMYYYY'),5,29,2,9,3);
INSERT INTO RX_pre scription VALUES(10,TO_DATE('24082001','DDMMYYYY'),5,30,0,1,4);
$
INSERT INTO RX_prescription VALUES(11, TO_DATE('26082001','DDMMYYYY'),6,20,0,1,5);
$
INSERT INTO RX_prescription VALUES(12,TO_DATE('27082001','DDMMYYYY'),6, 50,0,2,6);
$
INSERT INTO RX_prescription VALUES(13,TO_DATE('01092001','DDMMYYYY'),7,50,3,3,6);
INSERT INTO RX_prescription VALUES(14,TO_DATE('08092001','DDMMYYYY'),7,29,3,4,7);
INSERT INTO RX_prescription VALUES(15,TO_DATE( '12092001','DDMMYYYY'),8,40,2,5,8);
$
INSERT INTO RX_prescription VALUES(16,TO_DATE('18092001','DDMMYYYY'),8,20, 1,6,9);
$
INSERT INTO RX_prescription VALUES(17,TO_DATE('24092001','DDMMYYYY'),9,30,1,7,1);
INSERT INTO RX_prescription VALUES(18,TO_DATE('26092001','DDMMYYYY'),9,30,3,8,2);
$
INSERT INTO RX_prescription VALUES(19,TO_DATE('29092001 ", 'DDMMYYYY'),1,30,3,9,3 ); $
PROMPTCréationdela table RX_renouvellement
CREATE TABLE RX_renouvellement(
不, NUMBER(6),
DateRenou VARCHAR2(20),
Quantite NUMBER(4),
Prix NUMBER(7,2),
NoPres NUMBER(6),
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ bPROMPTCréationdescontraintesderéférence
ALTER TABLE RX_prescription
&NBSP;添加约束RX_prescription_NoCli_fk
&NBSP; FOREIGN KEY(NoCli)REFERENCES删除时RX_client(No)设置为null;
ALTER TABLE RX_prescription
&NBSP;添加约束RX_prescription_NoMedi_fk
&NBSP; FOREIGN KEY(NoMedi)参考文献RX_medicament(No);
$
ALTER TABLE RX_prescription
&NBSP;添加约束RX_prescription_NoDoc_fk
&NBSP; FOREIGN KEY(NoDoc)REFERENCES RX_docteur(No);
$
ALTER TABLE RX_renouvellement
&NBSP;添加约束RX_renouvellement_NoPres_fk
&NBSP; FOREIGN KEY(NoPres)REFERENCES删除级联时的RX_prescription(否);
DROP SEQUENCE seqClient;
DROP SEQUENCE seqPrescription;
DROP SEQUENCE seqMedicament;
DROP SEQUENCE seqMedecin;
DROP SEQUENCE seqRenou;
ALTER TABLE RX_prescription DROP CONSTRAINT RX_prescription_NoCli_fk;
ALTER TABLE RX_RENOUVELLEMENT DROP CONSTRAINT RX_renouvellement_NoPres_fk;
PROMPT Destruction des tables
DROP TABLE RX_client;
DROP TABLE RX_renouvellement;
DROP TABLE RX_medicament;
DROP TABLE RX_docteur;
DROP TABLE RX_prescription;
PROMPT Création des séquences
CREATE SEQUENCE seqClient START WITH 20;
CREATE SEQUENCE seqPrescription START WITH 20;
CREATE SEQUENCE seqMedicament START WITH 20;
CREATE SEQUENCE seqMedecin START WITH 20;
CREATE SEQUENCE seqRenou START WITH 20;
PROMPT Création de la table RX_client -- Prompt la ligne dans console
CREATE TABLE RX_client(
No NUMBER(6),
Prenom VARCHAR2(20) CONSTRAINT client_prenom_nn NOT NULL,
Nom VARCHAR2(15) CONSTRAINT client_nom_nn NOT NULL,
Rue VARCHAR2(30),
Ville VARCHAR2(12) DEFAULT 'Montréal',
Telephone CHAR(10),
CONSTRAINT RX_client_No_pk PRIMARY KEY (No));
PROMPT Création de la table RX_medicament
CREATE TABLE RX_medicament(
No NUMBER(5),
Nom CHAR(25),
Prix NUMBER(7,2),
CONSTRAINT RX_medicament_No_pk PRIMARY KEY (No));
PROMPT Création de la table RX_docteur
CREATE TABLE RX_docteur(
No NUMBER(5),
Prenom VARCHAR2(20),
Nom VARCHAR2(25),
Rue VARCHAR2(30),
Ville VARCHAR2(20) DEFAULT 'Montréal',
Telephone CHAR(10),
CONSTRAINT RX_docteur_No_pk PRIMARY KEY (No));
PROMPT Création de la table RX_prescription
CREATE TABLE RX_prescription(
No NUMBER(6),
DatePres DATE,
NoMedi NUMBER(5),
Quantite NUMBER(4),
NbRenou NUMBER(2),
NoCli NUMBER(6),
NoDoc NUMBER(6),
CONSTRAINT RX_NbRenou_ck CHECK (NbRenou IN (0,1,2,3,4,5,6,7,8,9,10)),
CONSTRAINT RX_Quantite_ck CHECK (Quantite <= 100),
CONSTRAINT RX_prescription_No_pk PRIMARY KEY (No));
INSERT INTO RX_prescription VALUES (1, TO_DATE('01072001','DDMMYYYY'),1,50,3,1,4);
INSERT INTO RX_prescription VALUES (2, TO_DATE('15072001','DDMMYYYY'),1,25,4,2,5);
INSERT INTO RX_prescription VALUES (3, TO_DATE('22072001','DDMMYYYY'),2,40,5,3,6);
INSERT INTO RX_prescription VALUES (4, TO_DATE('28072001','DDMMYYYY'),2,50,3,4,7);
INSERT INTO RX_prescription VALUES (5, TO_DATE('01082001','DDMMYYYY'),3,20,4,5,8);
INSERT INTO RX_prescription VALUES (6, TO_DATE('12082001','DDMMYYYY'),3,30,5,6,9);
INSERT INTO RX_prescription VALUES (7, TO_DATE('15082001','DDMMYYYY'),4,50,6,7,1);
INSERT INTO RX_prescription VALUES (8, TO_DATE('17082001','DDMMYYYY'),4,40,1,8,2);
INSERT INTO RX_prescription VALUES (9, TO_DATE('22082001','DDMMYYYY'),5,29,2,9,3);
INSERT INTO RX_prescription VALUES (10, TO_DATE('24082001','DDMMYYYY'),5,30,0,1,4);
INSERT INTO RX_prescription VALUES (11, TO_DATE('26082001','DDMMYYYY'),6,20,0,1,5);
INSERT INTO RX_prescription VALUES (12, TO_DATE('27082001','DDMMYYYY'),6,50,0,2,6);
INSERT INTO RX_prescription VALUES (13, TO_DATE('01092001','DDMMYYYY'),7,50,3,3,6);
INSERT INTO RX_prescription VALUES (14, TO_DATE('08092001','DDMMYYYY'),7,29,3,4,7);
INSERT INTO RX_prescription VALUES (15, TO_DATE('12092001','DDMMYYYY'),8,40,2,5,8);
INSERT INTO RX_prescription VALUES (16, TO_DATE('18092001','DDMMYYYY'),8,20,1,6,9);
INSERT INTO RX_prescription VALUES (17, TO_DATE('24092001','DDMMYYYY'),9,30,1,7,1);
INSERT INTO RX_prescription VALUES (18, TO_DATE('26092001','DDMMYYYY'),9,30,3,8,2);
INSERT INTO RX_prescription VALUES (19, TO_DATE('29092001','DDMMYYYY'),1,30,3,9,3);
PROMPT Création de la table RX_renouvellement
CREATE TABLE RX_renouvellement(
No NUMBER(6),
DateRenou VARCHAR2(20),
Quantite NUMBER(4),
Prix NUMBER(7,2),
NoPres NUMBER(6),
CONSTRAINT RX_renouvellement_qte_ck CHECK(
CONSTRAINT RX_renouvellement_No_pk PRIMARY KEY(No));
PROMPT Création des contraintes de référence
ALTER TABLE RX_prescription
ADD CONSTRAINT RX_prescription_NoCli_fk
FOREIGN KEY(NoCli) REFERENCES RX_client(No) on delete set null;
ALTER TABLE RX_prescription
ADD CONSTRAINT RX_prescription_NoMedi_fk
FOREIGN KEY(NoMedi) REFERENCES RX_medicament(No);
ALTER TABLE RX_prescription
ADD CONSTRAINT RX_prescription_NoDoc_fk
FOREIGN KEY(NoDoc) REFERENCES RX_docteur(No);
ALTER TABLE RX_renouvellement
ADD CONSTRAINT RX_renouvellement_NoPres_fk
FOREIGN KEY(NoPres) REFERENCES RX_prescription(No) on delete cascade;
推荐答案
这篇关于脚本不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!