tp2

download tp2

If you can't read please download the document

description

tp2 FPT

Transcript of tp2

create table eleve(numE int not null,nomC varchar(15),nomE varchar(15),constraint pk1 primary key(numE,nomC), constraint fk1 foreign key(nomC) REFERENCES classe(nomC))/*******create table prof(numP int not null,nomP varchar(15),constraint pk1 primary key(numP))/***create table ens(numP int not null,nomC varchar(15), nbr int not null, constraint pk1 primary key(numP,nomC), constraint fk1 foreign key(nomC) REFERENCES classe(nomC), constraint fk2 foreign key(numP) REFERENCES Prof(numP))/***********************INSERT INTO `ecole`.`eleve` (`numE`, `nomC`, `nomE`) VALUES ('13', 'RIBOUDINGUE', 'CE2'), ('14', 'TARZAN', 'CM1'), ('15', 'TINTIN', 'CM2'), ('16', 'MILOU', 'CE1'), ('17', 'SPIROU', 'CE2'), ('18', 'FANTASIO', 'CM1'), ('19', 'MICKEY', 'CM2'), ('20', 'DONALD', 'CE1'), ('22', 'BOULE', 'CE2'), ('23', 'BILL', 'CM1');INSERT INTO `ecole`.`classe` (`nomC`) VALUES ('CM1'), ('CM2'), ('CE1'), ('CE2');INSERT INTO `ecole`.`prof` (`numP`, `nomP`) VALUES ('P1', 'DUPONT'), ('P2', 'DUBOIS'), ('P3', 'DUGENOU'), ('P4', 'DURACUIRE'), ('P5', 'DUBALAI'), ('P6', 'DUVAL');INSERT INTO `ecole`.`ens` (`numP`, `nomC`, `nbr`) VALUES ('P1', 'CM1', '12'), ('P1', 'CM2', '25'), ('P2', 'CE1', '18'), ('P3', 'CE2', '30'), ('P3', 'CM2', '28'), ('P4', 'CE1', '15'), ('P4', 'CE2', '30'), ('P5', 'CE1', '32'), ('P5', 'CM1', '18'), ('P6', 'CE2', '28');select nume,nome from eleve where nomc in (select nomc from ens where nump=(select nump from prof where nomp='DUBALAI'));select nume,nome from eleve,ens,prof where nomp='DUBALAI' and prof.nump=ens.nump and ens.nomc=eleve.nomcselect sum(nbr) from ens,prof where prof.nump=ens.nump and nomp='dubalai'select nume,nome from eleve,ens,prof where nomp='DUBALAI' and prof.nump=ens.nump and ens.nomc=eleve.nomcshow tablesgrant insert on ecole.eleve to 'saad'@'localhost' identified by 'saad'describe nomeALTER TABLE `eleve` ADD `date` DATE NOT NULL AFTER `nomC`;ALTER TABLE `eleve` CHANGE `nomE` `nomeleve` VARCHAR(15) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '';alter table eleve drop nomeleveshow databasescreate user 'imad'@'localhost' identified by 'aliyalai'