0% found this document useful (0 votes)
45 views12 pages

Important Questions For Final Exam

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 12

Database Management System Important Questions for Final Exam

Important Questions for 2 Marks.


1. List any four advantages of DBMS.
2. Draw three level architecture of DBMS.
3. List four DDL commands with syntax.
4. Enlist DML commands.
5. List DCL commands.
6. List disadvantages of typical file processing system.
7. State the components used in E-R diagram.
8. Define i) data abstraction, ii) data redundancy.
9. State any four E.F. Codd’s rule for RDBMS.
10. Define the term: i) Candidate key ii) Primary key.
11. Define table and field.
12. Define primary key and foreign key.
13. Define data model. List its types.
14. Define normalization, list its types.
15. List any four string functions in SQL.
16. Enlist four aggregate functions.
17. State the use of Avg function with example.
18. List any four data types in SQL.
19. Write syntax for creating synonyms with example.
20. State any four PL/SQL data types.
21. List two advantages of PL/SQL.
22. State any two advantages of functions in PL/SQL.
23. Define cursor. List the two types of cursor.
24. Define View. Write syntax for creating and dropping View.
25. Define Trigger. Write syntax for creating and dropping trigger.
26. State types of database user.
27. State the concept of database recovery.
28. List ACID Properties of transaction.

Important Questions for 4 Marks.


1. With neat diagram explain three level architecture of database system.
2. Explain advantages of DBMS over file processing system.
3. Distinguish between network model and hierarchical model (any 4 points).
4. Explain overall structure of DBMS with the help of diagram.
5. State the difference between Relational and Hierarchical model.
6. Explain the four roles of database administrator.
7. Draw ER diagram for library management system considering issue and return,
fine collection facility. Consider appropriate entities.
8. Draw an ER diagram for library management system. (Use Books, Publisher
& Member entities).
9. Explain set operators with example.
10. Define Normalization. Explain 2NF with example.
11. State and explain 1NF and 2NF with example.
12. Explain difference between delete and truncate command with example.
13. List the SQL operations and explain range searching operation ‘between’ and
pattern matching operator ‘like’ with example.
14. State and explain 3NF with example.
15. Describe create & alter command with syntax & example.
16. Describe commit and rollback with syntax and example.
17. Explain any four string functions with example.
18. Explain joins in SQL with examples.
19. Explain any four aggregate functions with example.
20. Draw the block structure of PL/SQL. List advantages of PL/SQL.
21. Explain function in PL/SQL with example.
22. Explain any one control structure in PL/SQL with example.
23. Explain exception handling in PL/SQL with example.
24. Explain cursor with example.
25. State the use of database trigger and also list types of trigger.
26. Define index. Explain its types.
27. Define database trigger. How to create and delete trigger?
28. Write step by step syntax to create, open and close cursor in PL/SQL.
29. Describe the concept of view with example. State its purpose.
30. Explain database security with its requirements in detail.
31. Explain transaction ACID properties.
32. Explain state of transaction with the help of diagram.
33. Explain recovery techniques with example.
34. Describe database backups with its types.
Important Questions for 6 Marks with Answer.
1. Consider the following database
Employee(emp_id,emp_name,emp_city,emp_addr,emp_dept,join_date)
i) Display the emp_id of employee who live in city ‘Pune’ or
‘Nagpur’.
ii) Change the employee name ‘Ayush’ to ‘Ayan’.
iii) Display the total number of employee whose dept is 50.

Answer
i) select emp_id from Employee where emp_city=’Pune’ or
emp_city=’Nagpur’.

ii) update Employee set emp_name=’Ayan’ where emp_name=’Ayush’;

iii) Select count (*) from Employee where emp_dept=50;

2. Consider the following schema Depositor (ACC_no, Name, PAN, Balance).


Create a view on Depositor having attributes (ACC_No,PAN) where balance is
greater than 100000
Answer
Create view v1 as select ACC_No,PAN from Depositor where balance >
100000;

3. Create a sequence
i) Sequence name is Seq_1, Start with 1, increment by 1, minimum value 1,
maximum value 20.
ii) Use a seq_1 to insert the values into table Student( ID Number(10), Name
char
(20));
iii) Change the Seq_1 max value 20 to 50.
iv) Drop the sequence.
Answer
i) create sequence Seq_1 start with 1 increment by 1 minvalue 1 maxvalue
20;
ii) insert into student values(Seq_1.nextval,’ABC’);
iii) Alter sequence Seq_1 maxvalue 50;
iv) Drop sequence Seq_1;
4. Write a PL/SQL program which accepts the customer_ID from the user. If
the enters an invalid ID then the exception invalid_id is raised using
Exception handling.
Answer
DECLARE
c_id numeric(10);
invalid_id_Exception Exception;
BEGIN
c_id:=&c_id;
if(c_id<0) then
raise invalid_id_Exception;
end if;
EXCEPTION
WHEN invalid_id_Exception THEN
dbms_output.put_line('Invalid customer id');
END;

5. i) create user ‘Rahul’


ii) grant create, select,insert,update, delete, drop privilege to ‘Rahul’
iii) Remove the select privilege from user ‘Rahul’
Answer
(i) create user Rahul identified by rahul1234;
(ii)
1) assuming table Employee for granting permissions to user ‘Rahul’ for
select, insert, update and delete privilege)
Grant select, insert,update,delete on employee to Rahul;
2) for create and drop privilege which are system privileges not specific to
any object such as table
Grant connect, resource, DBA to Rahul;
iii) (Assuming table Employee for revoking permissions to user ‘Rahul’)
Revoke select on Employee from Rahul;

7. Consider the table Student (name, marks, dept, age, place, phone,
birthdate). Write SQL query for following.
i)To list students having place as ‘Pune’ or ‘Jalgaon’
ii)To list students having same department(dept) as that of ‘Rachana’
iii) To change marks of ‘Rahul’ from 81 to 96.
iv) To list student name and marks from ‘Computer’ dept.
v) To list student name who have marks less than 40.
vi)To list students who are not from ‘Mumbai;
Answer
i) select name from Student where place= ‘Pune’ or place=’Jalgaon’; (OR)
select name from Students where place in(‘Pune’,‘Jalgaon’);
ii)select name from Student where dept=(select dept from student where
name=’Rachana’);
iii)update Student set marks=96 where name= ‘Rahul’;
v)select name,marks from Student where dept=‘Computer’;
iv)select name from Student where marks

8. Create simple and composite index. Write command to drop above


index.
Answer
Create simple index
Syntax: Create index index_name on ; (OR)
E.g.: Create index idx_empno on employee (empno);
Create composite index:
Syntax: Create index index_name on <tablename><Column_name1,
Column_name2>;
(OR)
E.g.: Create index idx_ename_eno on employee (ename, empno);
Drop Index:
Syntax: Drop index <index_name>;
(OR)
E.g. (Assuming idx_empno created on employee table)
Drop index idx_empno;

9. i) Write a command to create table student(RNO,name marks,


dept) with proper datatypes and RNo as primary key
ii) Write a command to create and drop sequence.
Answer
) Write a command to create and drop sequence.
6M
Ans i) create table student( RNO number(5) constraint student_RNO_pk
primary key,name varchar2(20),marks number(4),dept varchar2(20));
(OR)
create table student(RNO number(5) ,name varchar2(20),marks number(4),
dept varchar2(20),constraint student_RNO_pk primary key(RNO));
ii) Create Sequence:
Create sequence <seq_name>
Start with [initial value]
Increment by [value]
Minvalue [minimum value]
Maxvalue [maximum value]
[cycle/no cycle]
[{cache value / No cache}]
[{order / No order}];

Drop sequence:
Drop sequence<Sequence Name>;
(OR)
Drop sequence emp_eno_seq;

10. Write a PL/SQL program to calculate factorial of a given number.


Answer
DECLARE
num number:=&num;
fact number:=1;
BEGIN
while num!=0
loop
fact:=fact*num;
num:=num-1
end loop;
dbms_output.put_line(‘Factorial =’||fact);
END;
/
(OR)
DECLARE
num number:=&num;
fact number:=1;
i number;
BEGIN
for i in 1..num loop
fact:=fact*i;
end loop;
dbms_output.put_line('Factorial='||fact);
END; /

11. Write SQL command for following


i) Create user
ii) Grant privileges to user.
Iii) Remove privileges from user.
Answer
i) Create user
CREATE USER <username> IDENTIFIED BY <password>;
(OR)
CREATE USER RAJ IDENTIFIED BY RAJ123;
ii) Grant privileges to user.
GRANT <privilege list> ON <relation name or view name>
TO<user list>;
(OR)
(Assuming table Employee for granting permissions to user ‘RAJ’
for select, insert, update and delete privilege)
GRANT SELECT, INSERT,UPDATE,DELETE ON
EMPLOYEE TO RAJ;
Iii) Remove privileges from user.
REVOKE <privilege list> ON <relation name or view name >
FROM <user list>;
(OR)
(assuming table Employee for revoking permissions to user ‘RAJ)
REVOKE SELECT, INSERT,UPDATE,DELETE ON
EMPLOYEE FROM RAJ;

12. Write a command to crate table student (rollno, Stud_name,


branch, class, DOB, City, Contact_no) and write down queries
for following:
(i) Insert one row into the table
(ii) Save the data
(iii) Insert second row into the table
(iv) Undo the insertion of second row
(v) Create save point S1.
(vi) Insert one row into the table.
Answer
SQL>Create table student(
Rollno number(5),
Stud_name char(10,
branch varchar(10),
class varchar(10),
DOB date,
city varchar(15),
Contact_no number(12)
);
(i) Insert one row into the table:
SQL>Insert into student values(1,‟Ram‟,‟CO‟,‟FirstYear‟,‟12-
jun-2001‟,‟Pune‟,98576867)
(ii) Save the data:
SQL> commit;
( OR )
SQL> commit work;
(iii)Insert second row into the table:
SQL>Insert into student values(2,‟Raj‟,‟CO‟,‟FirstYear‟,‟22-
Sep2002‟,‟Mumbai‟,98896863)
(iv)Undo the insertion of second row:
SQL> rollback;
( OR)
SQL> rollback work;
(v)Create savepoint s1:
SQL>Savepoint s1;
(vi) insert one row into the table:
SQL>Insert into student values(3,‟Beena‟,‟CO‟,‟FirstYear‟,‟30-
Dec-2002‟,‟Mumbai‟,97846455);

13. Consider following schema:


EMP (empno, deptno, ename, salary, designation, join_date,
DOB, dept_location). Write down SQL queries for following:
(i) Display employees name & number in decreasing order of
salary.
(ii) Display employee name & employee number whose
designation is Manager.
(iii) Display age of employees with ename.
(iv) Display total salary of all employees.
(v) Display employee names having deptno as 20 and
dept_location is Mumbai
(vi) Display name of employee who earned lowest salary.
Answer
(i)Display employees name &number in descending order of salary:
SQL> select ename,empno from EMP order by salary desc;
(ii) Display employee name & employee number whose designation
is Manager.
SQL> select ename,empno from EMP where designation=‟Manager‟;
(iii) Display age of employees with ename
SQL>select round ( (sysdate - DOB ) /365, 0 ) as “age”,ename
from EMP;
OR
select months_between(TRUNC(sysdate),DOB)/12 as “age”
,ename from EMP ;
(**Note consider any other logic also)
(iv)Display total salary of all employees.
SQL> select sum(salary) from EMP;
(v)Display employee names having deptno as 20 and dept_location is
Mumbai.
SQL> select enamefrom EMP where deptno=20 and
dept_location=‟Mumbai‟;
(vi)Display name of employee who earned lowest salary
SQL> select ename from EMP where salary=(select min(salary)
from EMP);

14. Consider the structure for book table as Book-Master (bookid,


bookname, author, no_of copies, price) Write down SQL queries for
following:
(i) Write a command to create Book_master table.
(ii) Get authorwise list of all books.
(iii) Display all books whose price is between 500 & 800.
(iv) Display all books with details whose name start with „D‟.
(v) Display all books whose price is above 700.
(vi) Display all books whose number of copies are less than 10.
Answer
(i)Write a command to create Book_Master table table.
SQL>Create table Book-Master(
bookid number(5),
bookname char(10),
authorvarchar(20),
no_of_copiesnumber(10),
price number(10,2)
);
(ii)Get authorwise list of all books.
SQL>Select sum(no_of copies) from Book_Master group by
author;
(iii)Display all books whose price is between Rs.500 & Rs. 800
SQL> Select * from Book_Master where price between 500 and
800;
OR
SQL> Select * from Book_Master where price >=500 and
price<=800;
(iv) Display all books with details whose name start with ‘D’
SQL> Select bookname from Book_Master where bookname like
„D%‟;
(v)Display all books whose price is above Rs. 700
SQL>Select * from Book_Master where price >700;
(vi) Display all books whose number of copies are less than 10
SQL>Select * from Book_Master where no_of_copies<10;

15. Write a PL/SQL program to print n even numbers using For


Loop.
Answer
declare
num number;
n number:=&n;
begin
for num in 1..n loop
if(mod(num,2)=0) then
dbms_output.put_line(‘Even no are :’||num);
end if;
end loop;
end;

16. Write the SQL queries for following EMP table. Emp (empno, deptno,
ename, salary, designation, city.)
i) Display average salary of all employees.
ii) Display names of employees who stay in Mumbai or Pune.
iii) Set the salary of employee 'Ramesh' to 50000.
iv)Display names of employees whose salaries are less than 50000.
v) Remove the Record of employees whose deptno is 10.
vi) Remove the column deptno from EMP table.
Answer
i. select avg(salary) from emp;
ii. select ename from emp where city=’Mumbai’ or city=’Pune’;
iii. update emp set salary=50000 where ename=’Ramesh’;
iv. select ename from emp where salary<50000;
v. delete from emp where deptno=10;
vi. alter table emp drop column deptno;

17. Write SQL queries for following. Consider table stud (roll no, name, subl,
sub2, sub3)
i) Display names of student who got minimum mark in subl.
ii) Display names of students who got above 40 marks in sub2.
iii) Display count of Students failed in sub2.
iv) Display average marks of subl of all students.
v) Display names of students whose name start with 'A' by arranging them
in ascending order of subl marks.
vi) Display student name whose name ends with h' and subject 2 marks are
between 60 to 75.
Answer
i. select name from stud where sub1= (select min(sub1) from stud);
ii. select name from stud where sub2>40;
iii. select count(*) from stud where sub2<40;
iv. select avg(sub1) from stud;
v. select name from stud where name like 'A%' order by sub1;
vi. select name from stud where name like '%h' and sub2 between 60 and 75;

18. Write a PL/SQL code to check whether specified employee is present in


Emp table or not. Accept empno from user. If employee does not exist
display message using exception handling.
Answer
declare
no emp.empno%type;
begin
no:=&no;
select empno into no from emp where empno=no;
dbms_output.put_line('Empno is present: '||no);
exception
when no_data_found then
dbms_output.put_line('Empno not present');
end;

19. Write SQL queries for following.


1) Create user named 'user1' having Password '1234
ii) Assign 'insert' and update' Privilege to 'userl".
ii) Remove update Privilege assigned to the userl.
iv) Assign the resource Pemission to userl.
Answer
i. create user user1 identified by 1234;
ii. grant insert, update on system.emp to user1;
iii. revoke update on system.emp from user1;
iv. grant create session, unlimited tablespace, create table to user1;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy