61 lines
1.5 KiB
MySQL
61 lines
1.5 KiB
MySQL
|
drop table Buveur if exists;
|
||
|
drop table Viticulteur if exists;
|
||
|
drop table Vin if exists;
|
||
|
drop table Commande if exists;
|
||
|
drop table Livraison if exists;
|
||
|
|
||
|
create table Buveur (
|
||
|
NumBuveur number primary key,
|
||
|
Nom Varchar2(25),
|
||
|
Prenom Varchar2(25)
|
||
|
Ville Varchar2(30));
|
||
|
|
||
|
|
||
|
|
||
|
Create table Viticulteur (
|
||
|
NumVitic Number Primary key,
|
||
|
Nom Varchar2(25) not null,
|
||
|
Prenom Varchar2(25),
|
||
|
Ville Varchar2 (30) not null );
|
||
|
|
||
|
Create table Vin (
|
||
|
NumVin Number,
|
||
|
Cru Varchar2(15) not null,
|
||
|
Millesime Number not null,
|
||
|
Region Varchar2(15) not null,
|
||
|
NumVitic Number not null references Viticulteur,
|
||
|
Primary key (NumVin));
|
||
|
|
||
|
Create table Commande (
|
||
|
NumCom Number Primary key,
|
||
|
NumBuveur Number not null references Buveur,
|
||
|
NumVin Number not null references Vin,
|
||
|
Qtte Number not null);
|
||
|
|
||
|
Create table Livraison (
|
||
|
NumCom Number not null references Commande,
|
||
|
Qtte Number not null,
|
||
|
DateLiv Date not null,
|
||
|
Primary key (NumCom, DateLiv));
|
||
|
|
||
|
|
||
|
insert into buveur values (2300, 'Valarcher', 'Pierre', 'Pinet');
|
||
|
delete from buveur where Numbuveur = 2300;
|
||
|
|
||
|
Insert into buveur (select * from laleau.buveur);
|
||
|
Insert into Viticulteur (select * from laleau.viticulteur)
|
||
|
Insert into Vin (select * from laleau.vin);
|
||
|
-- on rajoute une colonne à la table commande (nom de l'attribut datecom, type date)
|
||
|
alter table commande add datecom date;
|
||
|
insert into commande (select * from laleau.commande)
|
||
|
insert into livraison (elect * from laleau.livraison)
|
||
|
|
||
|
-- les tables sont remplies
|
||
|
|
||
|
-- A vous de regarder dedans
|
||
|
|
||
|
-- Avant de quitter faire
|
||
|
Commit;
|
||
|
|
||
|
|