Important Questions For Final Exam
Important Questions For Final Exam
Important Questions For Final Exam
Answer
i) select emp_id from Employee where emp_city=’Pune’ or
emp_city=’Nagpur’.
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;
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
Drop sequence:
Drop sequence<Sequence Name>;
(OR)
Drop sequence emp_eno_seq;
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;
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: