Sei sulla pagina 1di 4

create database agence_banquaire --- les tables create table agence ( num_agence int primary key, nom varchar(50),

ville varchar(50), actif int ) create table client ( num_client int primary key, nom varchar(50), vile varchar(50) ) create table compte ( num_compte int primary key, num_agence int foreign key references agence(num_agence), num_client int foreign key references client(num_client), solde money ) create table emprunt ( num_enprunt int primary key, num_agence int foreign key references agence(num_agence), num_client int foreign key references client(num_client), montant money ) ------------------------- les requetes -- 1 select * from agence where num_agence in (select compte.num_agence from compte) -- 2 select client.* from client,compte,agence where client.num_client=compte.num_client and compte.num_agence=agence.num_agence and agence.ville='rabat' ---select * from client where num_client in (select compte.num_client from compte,agence where compte.nu m_agence=agence.num_agence and agence.ville='rabat') -- 3 select distinct client.* from client,compte,agence,emprunt where (client.num_client=compte.num_client and compte.num_agence=agence.num_agence

and (agence.ville='rabat')) or ( client.num_client=emprunt.num_client and emprunt.num_agence=agence.num_agence and (agence.ville='rabat')) ----- union select client.* from client,compte,agence where (client.num_client=compte.num_client and compte.num_agence=agence.num_agence and (agence.ville='rabat')) union select client.* from client,emprunt ,agence where client.num_client=emprunt.num_client and emprunt.num_agence=agence.num_agence and (agence.ville='rabat') ---- in not in select * from client where num_client in (select compte.num_client from compte,agence where compte.nu m_agence=agence.num_agence and agence.ville='rabat') or num_client in (select emprunt.num_client from emprunt ,agence where emprunt.n um_agence=agence.num_agence and agence.ville='rabat') -- 4 select distinct client.* from client,compte,agence,emprunt where (client.num_client=compte.num_client and compte.num_agence=agence.num_agence and (agence.ville='rabat')) and ( client.num_client=emprunt.num_client and emprunt.num_agence=agence.num_agence and (agence.ville='rabat')) ----- intersection select client.* from client,compte,agence where (client.num_client=compte.num_client and compte.num_agence=agence.num_agence and (agence.ville='rabat')) intersect select client.* from client,emprunt ,agence where client.num_client=emprunt.num_client and emprunt.num_agence=agence.num_agence and (agence.ville='rabat') ---- in not in select * from client where num_client in (select compte.num_client from compte,agence where compte.nu m_agence=agence.num_agence and agence.ville='rabat') and num_client in (select emprunt.num_client from emprunt ,agence where emprunt. num_agence=agence.num_agence and agence.ville='rabat') ------- 5 select * from client where num_client in (select compte.num_client from compte,agence where compte.nu

m_agence=agence.num_agence and agence.ville='rabat') and num_client not in (select emprunt.num_client from emprunt ,agence where empr unt.num_agence=agence.num_agence and agence.ville='rabat') ------ 6 select client.* from client,compte,agence where compte.num_client=client.num_client and agence.num_agence=compte.num_agence and client.vile=agence.ville ----- 7 select distinct client.* from client,compte,agence where client.num_client=compte.num_client and compte.num_agence=agence.num_agence and agence.num_agence in (select agence.num_agence from agence,compte,client where agence.num_agence=compte.num_agence and compte.num_client=client.num_client and client.nom='abdelah') ---- 8 select * from agence where actif > (select MAX(actif) from agence where nom='cym') ---- 9 select client.* from client,compte,agence where client.num_client=compte.num_client and compte.num_agence=agence.num_agence and agence.nom='cym' ---- 10 select client.* from client,emprunt,agence where client.num_client=emprunt.num_client and emprunt.num_agence=agence.num_agence and agence.nom='temara-massira' order by client.nom asc ---- 11 select num_agence,avg(solde) from compte group by num_agence ---- 12 select num_agence,avg(solde) from compte group by num_agence having AVG(solde) > 10000 ---- 13 select COUNT(num_client) from client where ville='salle' ---- 14 select count(distinct compte.num_client) from compte,agence,client where agence.num_agence=agence.num_agence and client.num_client=compte.num_client and agence.nom='temara-centre'

and client.vile is null ---- 15 insert into client values(6,'said','tanger') --- 16 update emprunt set montant=montant -(montant * 0.05) where emprunt.num_client in (select num_client from client where vile='kenitra') ---- 17 delete from compte where compte.num_client=(select num_client from client where nom='rachid') ---- 18 delete from agence where agence.num_agence not in (select compte.num_agence from compte) and agence.num_agence not in (select emprunt .num_agence from emprunt )

Potrebbero piacerti anche