--- Vincent Hamel, hamv2701 14 162 988 ------------------------------------------------- drop table Aeroport cascade constraints; create table Aeroport ( codeaeroport varchar(20), ville varchar(20), etat varchar(20), nom varchar(20), constraint idaeroport primary key (codeaeroport), constraint idnom unique (nom) ); ------------------------------------------------- drop table Vol cascade constraints; create table Vol ( novol varchar(20), TypeDeVol varchar(20) check (TypeDeVol in ( régulier, nolisé )), constraint idnovol primary key (novol) ); ------------------------------------------------- drop table Classe cascade constraints; create table Classe( noclasse smallint not null, description varchar(20), constraint idnoclasse primary key (noclasse) ); ------------------------------------------------- drop table Avion cascade constraints; create table Avion ( noavion smallint not null, nomodele varchar(20), dateachat date, --- pas de time en oracle constraint idnoavion primary key (noavion) );
------------------------------------------------- drop table ClasseVol cascade constraints; create table ClasseVol ( noclasse smallint not null, novol varchar(20), prix numeric(9,2) not null, constraint idclassevol primary key (noclasse,novol), constraint prixnonneg check (prix>0 or prix=0), constraint novol_fk_vol foreign key (novol) references Vol, constraint noclasse_fk_noclasse foreign key (noclasse) references Classe ); ------------------------------------------------- drop table SegmentsDeVol cascade constraints; create table SegmentsDeVol ( novol varchar(20), nosegment integer not null, codeaeroportdepart varchar(20), codeaeroportarrivee varchar(20), dateheureprevuedepart timestamp, --- pas de time en oracle dateheureprevuearrivee timestamp, --- pas de time en oracle constraint idsegmentsdevol primary key (novol,nosegment), constraint novol_fk_vol2 foreign key (novol) references Vol, constraint codeaerodepart_fk_aeroport foreign key (codeaeroportdepart) references Aeroport, constraint codeaeroarrivee_fk_aeroport foreign key (codeaeroportarrivee) references Aeroport ); --constraint Depart_Avant_Arrivee check (dateheureprevuedepart > dateheureprevuearrivee) syntaxe? ------------------------------------------------- drop table AvionVol cascade constraints; create table AvionVol ( no_vol varchar(20), noavion smallint not null, constraint idavionvol primary key (no_vol,noavion), constraint novol_fk_vol3 foreign key (no_vol) references Vol, constraint noavion_fk_avion foreign key (noavion) references Avion );
------------------------------------------------- --- parti 3.1 insérer les valeur dans les tables insert into Aeroport (codeaeroport, ville, etat, nom) values ( YUL, Montreal, QC, Trudeau ); insert into Aeroport (codeaeroport, ville, etat, nom) values ( YYZ, Toronto, ON, Pearson ); insert into Aeroport (codeaeroport, ville, etat, nom) values ( CDG, Paris, FR, Charles-de-Gaulle ); insert into Avion (noavion, nomodele, dateachat) values (1, Boeing747,date 2010-09-08 ); insert into Avion (noavion, nomodele, dateachat) values (2, Airbus A380,date 2011-09-01 ); insert into Avion (noavion, nomodele, dateachat) values (3, Airbus A340, date 2012-08-01 ); insert into Vol (novol, typedevol) values ( AC2001, régulier ); insert into Vol (novol, typedevol) values ( AC2002, nolisé ); insert into SegmentsDeVol (novol,nosegment,codeaeroportdepart,codeaeroportarrivee,dateheureprevuedepart,dateheurepr evuearrivee) values ( AC2001,1, YUL, YYZ,timestamp 2014-01-02 13:00:00,timestamp 2014-01-02 14:00:00 ); insert into SegmentsDeVol (novol,nosegment,codeaeroportdepart,codeaeroportarrivee,dateheureprevuedepart,dateheurepr evuearrivee) values ( AC2001,2, YYZ, CDG,timestamp 2014-01-02 14:00:00,timestamp 2014-01-03 07:00:00 ); insert into Classe (noclasse,description) values (1, affaires ); insert into Classe (noclasse,description) values (2, économique ); insert into classevol (noclasse,novol,prix) values (1, AC2001,1010.02); insert into classevol (noclasse,novol,prix) values (2, AC2001,300.03); insert into avionvol (no_vol,noavion) values ( AC2001,1); insert into avionvol (no_vol,noavion) values ( AC2002,2); --- Parti 3.2 change la province QC pour QUEBEC dans tous les aéroports update Aeroport set etat= Quebec where etat= QC ; --- Parti 3.3 double le prix des vols en classe Affaires update ClasseVol set prix=prix2 where noclasse=1;
--- Parti 3.4 Supprime les avions contenant Airbus A340 dans leur modele Delete from Avion where nomodele= Airbus A340 ; SQLPlus: Release 11.2.0.2.0 Production on Mon Sep 29 11:21:19 2014 Copyright (c) 1982, 2010, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options début de test-tp1.sql PL/SQL procedure successfully completed. drop table Aeroport cascade constraints drop table Vol cascade constraints drop table Classe cascade constraints
drop table Avion cascade constraints drop table ClasseVol cascade constraints drop table SegmentsDeVol cascade constraints drop table AvionVol cascade constraints
1 row updated.
1 row updated. 1 row deleted. Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options