Sie sind auf Seite 1von 9

1-(a)Create a table to represent sb_account of a bank consisting of account_no,customername , balance-amount.(b)Write a PL/SQL block to implement deposit and withdraw.

Withdrawshould not be allowed if the balance goes below Rs.1000 2-Create the following two tables:College-infoCollege-infoCollege-info consists of fields : college-code, college-name,addressFaculty-info consists of fields : college-code, faculty-code, faculty-name,qualification, college-code is foreign key.(a)Generate queries to do the following:(i) List all those faculty members whose experience is greater than or equal to 10 years and have M.Tech degree.(ii) List all those faculty members, who have at least 10 years of experience but do not have M.Tech degree. 3-Create the following tables for library-information systems :Book: (Accession -no, title, publisher, author, status)Status could be issued, present, in the library, dent for binding, andcannot be issued.(a)Write a trigger which sets the status of a book to cannot be issued , if it is published 20 years back 4-Create the following tables for library-information systems :Book : (Accession- no, title, publisher, author, status, date-of -purchase)Status could be issued, present, in the library, dent for binding, andcannot be issued.Generate queries to do the following :(i) List all those books which are new arrivals. The books which arerequires during the last 6 months are categorized as new arrivals.(ii) List all those books that cannot be issued and purchased 20 years ago 5-Create the following tables:Student (roll-no, name, date-of-birth, course-id)Course (course-id, name, fee, duration)(a)Generate the queries to do the following:(i) List all those students who are greater than 18 years of age and have opted or MCA course.(ii) List all those courses whose fee is grater than that of MCA course. 6-Create the following table :Student(roll-no,name subject-opted)Subject(faculty-code, faculty-name, specialization)(a)Generate queries to do the following :(i) Find the number of students who haveenrolles for the subjectDBMS(ii) Find all those faculty members who have not offered any subject. 7-Create the following table :Item (item-code, item-name, qty-in-stock, reorderlevel)Supplier (supplier-code, supplier-name, address)Can-Supply (supplier-code, itemcode)(a) Generate queries to do the following:(i) List all those suppliers who can supply the given item.(ii) List all those items which cannot be supplied by given company. 8-Create the following table:Student(roll-no,marks,category, district, state)Studentrank(roll-no, marks,rank)(a)Generate queries to do the following :(i) List all those students who have come from tamilnadu state andsecured a rank above 100.(ii) List all those students who have come from Anshra Pradesh stateand belong togiven category who have secured a rank above 100.

9-Create the following table:Branch (branch-id, branch-name, branch-city)Customer (customer-id, customer-name, customer-city, branch-id)(a) Generate queries to do the following:(i) List all those customers who live in the same city as the branch inwhich theyhave account.(ii) List all those customers who have an account in a given branch city. 10-Create the following tables:Book (accession no, title, publisher, year, date-of-purchase, status)Member (member-id, number-of-books-issued, max-limit)Book-issue(accession-no, member-id, date-of-issue)(a) Generate the following to do the following:(i) List all those books which are due from the students to be returned. Abook is considered to be issued 15 days back and yet not returned.(ii) List all those members who cannot be issued any more books. 11-create the following tables: Book (accession no, title, publisher, year, date-of-purchase, status) Member (member-id, number-of-books-issued, max-limit) Book-issue (accession-no, member-id, date-of-issue)(a) Write a PL/SQL procedure to issue the book.(b)Write a trigger to set the status of student to back listed if they havetaken book but not returned even one year. 12-Create the followingBook (accession-no, title, publisher, year, date-of-purchase)Bookplace (accession-no, rack-id, rack-position)Member (member-id, name, number-of-booksissued, max-limit, status)Book-issue (accession-no, member-id, date-of-purchase)(a) Write a PL/SQL procedure to issue the book (b) Write a trigger to set the status of the book neither to lost which isneither issued nor in the library. 13-Create the followingBook (accession-no, title, publisher, year, date-ofpurchase)Member (member-id, name, number-of-books-issued, max-limit, status)Bookissue (accession-no, member-id, date-of-purchase ,due-date)(a) Write a PL/SQL to list all those students who are defaulters. Astudentis considered to be a defaulter if he has not returned a book evenafter the due-date(b) Write a trigger to set the status of the student to back listed if theyhave taken book but not returned even after one year. 14-Create the following tables:Branch (branch-id, branch-name, branch_-city)Customer (customer-id, customer-name, customer-city, branch-id)(b) Generate queries to do the following:(i) List all those customers who live in the same city as the branch inwhich they have account.(ii) List all those customers who have an account in more than one branch. 15-Create the following tables:Branch (branch-id, branch-name, branch_-city)Customer (customer-id, customer-name, customer-city, branch-id)(a) Generate queries to do the following:(i)List all those branches who have more than 2 customers.(ii) List all those customers who have an account in more than one branch. 16-Create the following table:Student (roll-no, name, category, district, state) Student-rank (roll-no, marks, rank)(b) Generate queries to do the following :(i) List names of the students who are having same rank bur they shouldreside in different districts.(ii) List details of students they belongs to same category with same tank.

17-Create the following tables:Student (roll-no, name, date-of-birth, course-id)Course (course-id, name, fee, duration)(a) Generate queries to do the following:(i) List all those student who are between 10-19 years of age and haveopted for MCAcourse.(ii) List all those courses in which number of students are less than 10. 18-Create the following tables:Student (roll_no, name,date_of_birth,course-id)Course (course-id, name, fee, duration, status)(a) Write PL/SQL procedure to do the following:Set the status of course to not offered in which the number of candidate is less than 5. 19-Create the following tables:Student (roll_no, name,date_of_birth,course-id)Course (course-id, name, fee, duration, status)(a) Write PL/SQL procedure to do the following:Set the status of course to not offered in which the number of candidate is less than 5. 20-Create the following tables:Student (roll-no, name, date_of_birth, course-id)Course (course-id, name, fee, duration, status)(a) Write PL/SQL procedure to do the following:Set the status of course to offered in which the number of candidate areat least 10 otherwise not offered. 21-Create the following tablesItem(item_code,item_name,qty_in_stock,reorder_level)Supplier(supplier_code,suppli er_name,address)Can_supply(supplier_code,item_code)(a)Create a form to accept the data from the user with appropriatevalidation checks(b)Create a report to list the items whose qty_in_stock is less than or equal to their reorder levels. 22-Create the following table :Item (item-code, item-name, qty-in-stock, reorder-level) Supplier (supplier-code, supplier-name, address) Can-Supply (supplier-code, item-code)(a)Write PL/SQL procedure to do the following:Set the status of the supplier to important if the supplier can supplymore than five items. 23-create the following tablesItem(item_code,item_name,qty_in_stock,reorder_level)Supplier(supplier_code,suppli er_name,address,status)Can_supply(supplier_code,item_code)(a)Create a form to accept the data from the user with appropriatevalidation checks(b)Write PL/SQL procedure to do the following(i) Generate a report of those items that are supplied by those supplierswhose status isimportant. 24-create the following tablesStudent(roll_no,marks,category,district,state)Student_rank(roll_no,marks,rank) (a)Create a form to accept the data from the user with appropriatevalidation checks. (b)Write a PL/SQL procedure to do the following(i)Generate a report to list of those districts from which the first hundredrankers come from. 25-create the following tablesStudent(roll_no,name,subject_opted)Subject_rank(subject_code,subject_name,facult y_code,status)Faculty(faculty_code,faculty_name,specialization)(a)Write a PL/SQL

procedure to the following:Set the status of the subject to not offered if the subject is not optedby at least 5 students. 26-create the following tablesStudent(roll_no,name,subject_opted)Subject_rank(subject_code,subject_name,facult y_code,status)Faculty(faculty_code,faculty_name,specialization)(a)Write a PL/SQL procedure to the following:Set the status of the subject to not offered if the subject is not offeredby any of the faculty members. 27-create the following tablesStudent(roll_no,name,subject_opted)Subject_rank(subject_code,subject_name,facult y_code)Faculty(faculty_code, faculty_name, specialization)(a)Generate the queries to do the following( i ) F i n d th e n umber of s t ud en ts wh o h av e en r ol l ed f or th e s u b j ec t DBMS. (ii)Find all those subjects which are not offered by any faculty member. 28-create the following tablesStudent(roll_no,name,subject_opted)Subject_rank(subject_code,subject_name,facult y_code)Faculty(faculty_code, faculty_name, specialization)(a)Generate the queries to do the following( i ) Fi n d th e n umb er of s tu d en t s wh o h av e en ro ll ed f or th e s u bj ec t DBMS.(ii)Find all those subjects which are offered by more than one facultymember. 29-create the following tablesStudent(roll_no,name,subject_opted)Subject_rank(subject_code,subject_name,facult y_code)Faculty(faculty_code, faculty_name, specialization)(a)Generate the queries to do the following(i)Find the number of students who have enrolled for the subjectOS.(ii)Find all those students who have opted for more than 5 subjects. 30-create the following tablesStudent(roll_no,name,subject_opted)Subject_rank(subject_code,subject_name,facult y_code)Faculty(faculty_code, faculty_name, specialization)(a)Generate the queries to do the following(i)Find the number of students who have not enrolled for the subjectDBMS.(ii)Find all those subjects which are offered by more than one facultymember. 1-Steps For Creating A Data Source. 2-Steps To Create A Form 3-Steps To Generate A Report. ==

Answers:
1. (a)Create a table to represent sb_account of a bank consisting of account_no,customer-name , balance-amount. (b)Write a PL/SQL block to implement deposit and withdraw. Withdraw should notbe allowed if the balance goes below Rs.1000. solution: SQL> create table sb_account2 ( ACC_NO varchar(10) primary key,3 cust_name varchar(15),4 balance number(10)); -Table created inserting values into tables: SQL> insert into sb_account values 2 ('&ACC_NO','&cust_name',&balance); Enter value for acc_no: 101 Enter value for cust_name: abcd Enter value for balance: 15000 old 2: ('&ACC_NO','&CUST_NAME','&BALANCE') new 2: ('101','abcd','15000') 1 row created.

SQL> / Enter value for acc_no: 102 Enter value for cust_name: defg Enter value for balance: 1000 old 2: ('&ACC_NO','&CUST_NAME','&BALANCE') new 2: ('102','defg','1000') 1 row created. SQL> select * from sb_account; ACC_NO -----------101 102 103 104 CUST_NAME ----------------abcd defg fhdkd dfhdl BALANCE -------------15000 1000 2000 25000

(b) PL/SQL Code: SQL> declare 2 bal number(10); 3 acno varchar(10); 4 min_bal constant number(7,2):=1000.00;

5 amount number(10); 6 ch number(1); 7 begin 8 dbms_output.put_line(to_char(1)||'.deposit'); 9 dbms_output.put_line(to_char(2)||'.Withdraw'); 10 dbms_output.put_line('enter choice'); 11 ch:=&ch; 12 acno:=&acno; 13 select balance into bal from sb_account where acc_no=acno; 14 amount:=&amount; 15 if(ch=1) then 16 update sb_account set balance=balance+amount where acc_no=acno; 17 dbms_output.put_line('deposited'); 18 else 19 if (bal-amount)<min_bal then 20 dbms_output.put_line('cant withdraw'); 21 else 22 update sb_account set balance=balance-amount where acc_no=acno; 23 dbms_output.put_line('withdrawn'); 24 end if; 25 end if; 26* end; SQL> / Enter value for ch: 1 old 11: ch:=&ch; new 11: ch:=1; Enter value for acno: 101 old 12: acno:=&acno; new 12: acno:=101; Enter value for amount: 1000 old 14: amount:=&amount; new 14: amount:=1000; 1.deposit 2.Withdraw enter choice deposited PL/SQL procedure successfully completed. SQL> select * from sb_account;

ACC_NO CUST_NAME ---------- --------------- ---------101 abcd 16000 102 defg 1000 103 fhdkd 2000 104 dfhdl 25000

BALANCE

SQL>/ (reexecuting yhe same PL/SQL code) Enter value for ch: 2 old 11: ch:=&ch; new 11: ch:=2; Enter value for acno: 102 old 12: acno:=&acno; new 12: acno:=102; Enter value for amount: 1000 old 14: amount:=&amount; new 14: amount:=1000; enter choice 1.deposit 2.Withdraw cant withdraw PL/SQL procedure successfully completed. SQL> / (reexecuting yhe same PL/SQL code) Enter value for ch: 2 old 11: ch:=&ch; new 11: ch:=2; Enter value for acno: 103 old 12: acno:=&acno; new 12: acno:=103; Enter value for amount: 1000 old 14: amount:=&amount; new 14: amount:=1000; enter choice 1.deposit 2.Withdraw withdrawn

PL/SQL procedure successfully completed. SQL> select * from sb_account; ACC_NO CUST_NAME ---------- --------------- ---------101 abcd 16000 102 defg 1000 103 fhdkd 1000 104 dfhdl 25000 BALANCE

2. Create the following two tables:College-info. College-info College-info consists of fields : college-code, college-name, address Faculty-info consists of fields : college-code, faculty-code, faculty-name, qualification,college-code is foreign key.(a) Generate queries to do the following:(i) List all those faculty members whose experience is greater than or equalto 10 years and have M.Tech degree.(ii) List all those faculty members, who have at least 10 years of experiencebut do not have M.Tech degree. SQL>create table college_info.(college_code number(5) primary key,college_name varchar(15),address varchar(15)); Table created. SQL>create table faculty_info2 ( faculty_code number(5) primary key,3 college_code number(5),4 faculty_name varchar(15),5 qualification varchar(15),6 experience number(2),7 address varchar(15),8constraints fk foreign key(college_code) references college_info(college_code )); table created. SQL> insert into college_info values 2 (&college_code,'&college_name','&address'); Enter value for college_code: 101 Enter value for college_name: xyz Enter value for address: old alwal 1; old 2: (&college_code,'&college_name','&address') new 2: (101,'xyz','old alwal 1;') 1 row created. SQL> /Enter value for college_code: 202 Enter value for college_name: abc Enter value for address: old alwal 2; old 2: (&college_code,'&college_name','&address') new 2: (202,'abc','old alwal 2;') 1 row created

SQL> insert into faculty_info values(&faculty_code,&college_code,'&faculty_name','&qualification','&experience',' &address') Enter value for faculty_code: 1111 Enter value for college_code: 101 Enter value for faculty_name: ssss Enter value for qualification: M.Tech Enter value for experience: 10 Enter value for address: zzzzzzz old 2: (&faculty_code,&college_code,'&faculty_name','&qualification','&experience','&addre ss') new 2: (1111,101,'ssss','M.Tech','10','zzzzzzz') 1 row created. SQL> /Enter value for faculty_code: 2222 Enter value for college_code: 202 Enter value for faculty_name: yyyy Enter value for qualification: M.Phil Enter value for experience: 20 Enter value for address: xxxxxx old2: (&faculty_code,&college_code,'&faculty_name','&qualification','&experience','&addre ss') new 2: (2222,202,'yyyy','M.Phil','20','xxxxxx') 1 row created. SQL> select * from college_info;

Das könnte Ihnen auch gefallen