Sunteți pe pagina 1din 3

BD (test la laborator partea a doua ianuarie 2012)

grupul I de tabele setul 1 1. Sa se afiseze dintr-un bloc anonim PL/SQL, folosind un cursor explicit, anul, matricola, numele si prenumele studentului, media lui, ordonat dupa an si dupa numele studentului. 2. Dintr-un bloc anonim PL/SQL, folosind un cursor explicit, sa se elimine din tabela note studenti cea mai mica nota a fiecarui student. Daca sunt mai multe astfel de note, sa se elimine una singura la intamplare. grupul II de tabele setul 3 1. Sa se afiseze dintr-un bloc anonim PL/SQL, folosind un cursor explicit, tipul taxei, denumirea ei si suma totala achitata pentru acea taxa in ordinea crescatoare a tipului si codului taxelor. 2. Dintr-un bloc anonim, folosind un cursor explicit, sa se elimine din tabela incasari toate incasarile corespunzatoare taxelor pentru care s-au platit cele mai mari sume (daca V este valoarea maxima platita intre sumele platite pentru toate taxele sa se elimine din incasari toate incasarile pentru taxele pentru care valoarea totala a platilor este V).

-- grupul 1 de tabele DROP TABLE studenti CASCADE CONSTRAINTS; CREATE TABLE studenti ( mat NUMBER(4) PRIMARY KEY, nume VARCHAR2(20), prenume VARCHAR2(20), an NUMBER(1) ); DROP TABLE obiecte CASCADE CONSTRAINTS; CREATE TABLE obiecte ( cod NUMBER(3) PRIMARY KEY, den VARCHAR2(20), an NUMBER(1) );

-- matricola studentului -- anul de studii al studentului

-- codul materiei -- anul de studiu al obiectului

DROP TABLE note_studenti CASCADE CONSTRAINTS; CREATE TABLE note_studenti ( mat NUMBER(4) REFERENCES studenti( mat ), cod NUMBER(3) REFERENCES obiecte( cod ), nota NUMBER(5,2) ); INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO studenti studenti studenti studenti studenti studenti studenti studenti studenti studenti studenti studenti studenti obiecte obiecte obiecte obiecte obiecte obiecte obiecte obiecte VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES (1001,'nume1','prenume1',2); (1002,'nume2','prenume2',2); (1003,'nume3','prenume3',2); (1004,'nume4','prenume4',1); (1005,'nume5','prenume5',1); (1006,'nume6','prenume6',1); (1007,'nume7','prenume7',3); (1008,'nume8','prenume8',3); (1009,'nume9','prenume9',3); (1010,'nume10','prenume10',3); (1011,'nume12','prenume11',4); (1012,'nume13','prenume12',4); (1013,'nume14','prenume13',4);

VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES

(101,'den1',2); (102,'den2',2); (103,'den3',1); (104,'den4',1); (105,'den5',3); (106,'den6',3); (107,'den7',4); (108,'den8',4); (1004,103,7); (1005,104,6); (1006,103,9); (1001,103,5); (1002,103,3); (1003,103,8); (1001,104,9); (1002,104,6); (1003,104,7); (1001,101,5); (1002,101,3); (1003,102,8); (1007,103,7); (1008,104,6); (1009,103,9); (1010,103,5); (1011,103,3); (1008,103,8); (1009,104,9); (1007,104,6); (1010,104,7); (1009,101,5); (1007,101,3); (1008,102,8); (1008,102,8); (1012,107,8); (1012,105,6); (1012,103,3);

note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti note_studenti

VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES

-- grupul 2 de tabele DROP TABLE contribuabili CASCADE CONSTRAINTS; CREATE TABLE contribuabili ( cod NUMBER(4) PRIMARY KEY, nume VARCHAR2(40), tip NUMBER(1) ); DROP TABLE taxe CASCADE CONSTRAINTS; CREATE TABLE taxe ( cod NUMBER(3) PRIMARY KEY, den VARCHAR2(20), tip NUMBER(1) ); DROP TABLE incasari CASCADE CONSTRAINTS; CREATE TABLE incasari ( codc NUMBER(4) REFERENCES contribuabili( cod ), codt NUMBER(3) REFERENCES taxe( cod ), suma NUMBER(12,2) ); INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INSERT INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO INTO contribuabili contribuabili contribuabili contribuabili contribuabili contribuabili contribuabili contribuabili contribuabili contribuabili taxe taxe taxe taxe taxe taxe taxe VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES (1001,'nume1',1); (1002,'nume2',1); (1003,'nume3',1); (1004,'nume4',1); (1005,'nume5',2); (1006,'nume6',2); (1007,'nume7',2); (1008,'nume8',2); (1009,'nume9',2); (1010,'nume10',2);

(101,'taxa1',1); (102,'taxa2',1); (103,'taxa3',1); (104,'taxa4',1); (105,'taxa5',2); (106,'taxa6',2); (107,'taxa7',2); (1001,101,200); (1001,102,100); (1001,103,300); (1001,104,200); (1002,101,200); (1002,102,100); (1002,103,300); (1003,104,200); (1003,102,100); (1003,103,300); (1005,105,300); (1005,106,100); (1005,107,400); (1007,106,100); (1007,107,400);

incasari incasari incasari incasari incasari incasari incasari incasari incasari incasari incasari incasari incasari incasari incasari

VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES VALUES

S-ar putea să vă placă și