You are on page 1of 6

Create view V_EMP

As select Num_Emp,Nom_Emp,Salaire_Emp,Num_Dep,departement.ville_Dep

From employee

Inner join departement

On employee.Num_Dep=departement.Num_Dep ;

CREATE view fouad

as select Num_Emp,fonction_emp

from employee

where Num_Emp=5
Ex1

create table Usine(

NumU integer,

NomU varchar(10),

VilleU varchar(30))

create Table Produit(

NumP integer,

NomP varchar(30),

Couleur varchar(30))

create table Fournisseur (

NumF integer,

NomF varchar(30),

Domaine varchar(30),

VilleF varchar(30))

create table PUF (

NumP integer,

NumU integer,

NumF integer,

quantité integer,

date date)

insert into Usine values

(U1,' Usine 1','Paris'),

(U2,' Usine 2','Londres'),

(U3,' Usine 3','Madrid') ;


insert into Produit values

(P1,' Produit 1','Noir'),

(P2,' Produit 2','Blanc'),

(P3,' Produit 3','Rouge') ;

insert into Fournisseur values

(F1,' Fournis 1',' Informatique ',' Beyrouth'),

(F2,' Fournis 2',' Electronique ',' Achrafieh'),

(F3,' Fournis 3',' Alimentation ',' Zahle') ;

insert into PUF values

(P1,'U1','F1',50,'2023-04-03'),

(P2,'U2','F2',26,' 2023-02-05'),

(P3,'U 3','F3',31,' 2023-04-19') ;

DELETE FROM Produit

WHERE Couleur=‘Noire'

UPDATE Fournisseur SET Ville=’Sour’ WHERE NumF=F3

Ex2

insert into CLIENT values

(1,'NOM1','RUE1',40000,'VILLE1','00000000'),

(2,'NOM2','RUE2',50000,'VILLE2','07222222'),

(3,'NOM3','RUE3',60000,'VILLE3','08333333')
insert into ECHANTILLON values

(1,'2022-12-05',3),

(2,'2023-03-10',2),

(3,'2023-04-01',1)

insert into TYPEANALYSE values

(1, 'Designation1', 'TYPE1',100),

(2, 'Designation2', 'TYPE2',40),

(3, 'Designation3', 'TYPE3',50)

insert into REALISER values

(1,3,'2023-01-06'),

(2,1,'2023-03-20'),

(3,2,'2023-04-12')

update TYPEANALYSE set PrixTypeAnalyse=PrixTypeAnalyse+(PrixTypeAnalyse*10/100)

update TYPEANALYSE set PrixTypeAnalyse=80 where PrixTypeAnalyse<80

update REALISER set DateRealisation=’04/20/2023’

update CLIENT set Tel='0611111111' where codeClient='1'

update ECHANTILLON set DateEntree='2022-12-15' where DateEntree='2022-12-05'


create table AnalyseDispo(

RefTypeAnalyse int primary key,

designation varchar(50),

TypeAnalyse varchar(50),

prixTypeAnalyse int)

insert into AnalyseDispo values

(4, 'Designation4', 'TYPE4',200),

(5, 'Designation5', 'TYPE5',300),

(6, 'Designation6', 'TYPE6',400)

insert into TYPEANALYSE select * from AnalyseDispo

td4 ex3

1) select Nom_Emp,Fonction_Emp
from `d_employee`
where Salaire_Emp>(
select Salaire_Emp from `d_employee`
where Nom_Emp='Fadi')

2) select Fonction_Emp
from `d_employee`
group by Fonction_Emp
having AVG(Salaire_Emp)< (
select AVG(Salaire_Emp)
from `d_employee`
where Fonction_Emp='Ouvrier')
select e.*
from `d_employee` e
inner join `d_departement` d
on e.`Num_Dep`=d.`Num_Dep`
where d.`Ville_Dep`='Paris'
UNION
select e.*
from `d_employee` e
inner join `d_travailler` t
on e.`Num_Emp`=t.`Num_Emp`
inner join `d_projet` p
on t.`code_proj`=p.`code_proj`
where p.`nom_proj`='web

select *
from `d_employee`
where `Num_Emp` not in (
select `Num_Emp`
from `d_travailler`)

select distinct p.*


from `d_projet` p
inner join `d_travailler` t
on p.Code_Proj=t.Code_Proj
where t.Code_Proj in (
select distinct p.Code_Proj
from `d_projet` p
inner join `d_travailler` t
on p.Code_Proj=t.Code_Proj
inner join `d_employee` e
on t.Num_Emp=e.Num_Emp
where e.Fonction_Emp ='Ouvrier'

You might also like