105 lines
1.9 KiB
Plaintext
Executable File
105 lines
1.9 KiB
Plaintext
Executable File
|
|
Q1)
|
|
CREATE TABLE AUTEUR
|
|
NumAuteur number primary key,
|
|
NomAuteur Varchar(20)
|
|
);
|
|
|
|
Insert into AUTEUR
|
|
VALUES
|
|
(1,'wamster');
|
|
Insert into AUTEUR
|
|
VALUES
|
|
(2,'Wiliatt');
|
|
Insert into AUTEUR
|
|
VALUES
|
|
(3,'Schnur');
|
|
Insert into AUTEUR
|
|
VALUES
|
|
(4,'JKwroling');
|
|
Insert into AUTEUR
|
|
VALUES
|
|
(5,'Squeezie');
|
|
Insert into AUTEUR
|
|
VALUES
|
|
(6,'Lov');
|
|
Insert into AUTEUR
|
|
VALUES
|
|
(7,'Apolinaire');
|
|
|
|
|
|
CREATE TABLE EDITEUR
|
|
(CodeEditer number primary key,
|
|
RaisonSociale Varchar(50)
|
|
);
|
|
|
|
Insert into EDITEUR
|
|
VALUES (1,'FOU');
|
|
Insert into EDITEUR
|
|
VALUES (2,'RIEN');
|
|
Insert into EDITEUR
|
|
VALUES (3,'PERSONNE');
|
|
Insert into EDITEUR
|
|
VALUES (4,'INTELLIGENT');
|
|
Insert into EDITEUR
|
|
VALUES (5,'SKIZOFRIEND');
|
|
|
|
|
|
|
|
2)
|
|
----------------------------------------------
|
|
RAPPEL:
|
|
<nom_attribut> (type_attribut> REFERENCES <table_parente>
|
|
(ON DELETE / ON UPDATE) (CASCADE / SET DEFAULT / SET NULL)
|
|
----------------------------------------------
|
|
|
|
CREATE TABLE LIVRE
|
|
(NumLivre number primary key,
|
|
Titre Varchar(60),
|
|
CodeEditeur number references EDITEUR ON DELETE SET NULL
|
|
);
|
|
|
|
INSERT INTO LIVRE
|
|
VALUES (1,'Harry Potter',4);
|
|
INSERT INTO LIVRE
|
|
VALUES (2,'Tournes la page',3);
|
|
INSERT INTO LIVRE
|
|
VALUES (3,'Roger et ses humains',3);
|
|
INSERT INTO LIVRE
|
|
VALUES (4,'devenir courreur pro en 10 conseils',1);
|
|
INSERT INTO LIVRE
|
|
VALUES (5,'geu',1);
|
|
|
|
DELETE FROM EDITEUR WHERE RaisonSociale='PERSONNE';
|
|
|
|
SELECT *
|
|
FROM LIVRE;
|
|
|
|
|
|
|
|
3)
|
|
|
|
CREATE TABLE A_ECRIT
|
|
(NumAuteur number references AUTEUR ON DELETE SET NULL,
|
|
NumLivre number references LIVRE ON DELETE CASCADE,
|
|
Primary key(NumAuteur,NumLivre)
|
|
);
|
|
|
|
INSERT INTO A_ECRIT
|
|
VALUES (1,4);
|
|
INSERT INTO A_ECRIT
|
|
VALUES (2,5);
|
|
INSERT INTO A_ECRIT
|
|
VALUES (4,1);
|
|
INSERT INTO A_ECRIT
|
|
VALUES (5,2);
|
|
INSERT INTO A_ECRIT
|
|
VALUES (6,3);
|
|
|
|
DELETE FROM Livre WHERE Titre='devenir courreur pro en 10 conseils';
|
|
SELECT * FROM A_ECRIT;
|
|
|
|
|
|
DELETE FROM AUTEUR WHERE NomAuteur='Lov';
|
|
|