0% found this document useful (0 votes)
29 views3 pages

DMS Assignment No3

Uploaded by

dhananjay mane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views3 pages

DMS Assignment No3

Uploaded by

dhananjay mane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Unit 3: Interactive SQL and Advance SQL: SQL Performance Tuning

Q: Important Question.(Marks 2)
1. Enlist four aggregate functions.
2. Write syntax for creating synonyms with example.
3. Write syntax for creating and dropping views.
4. State the use of Avg function with example.
5. List any four string functions in SQL.
6. Describe the concept of view with example. State its purpose.
Q: Important Question.(Marks 4)
1. Explain any four string functions with example.
2. Explain joins in SQL with examples.
3. Write and explain syntax for creating view with example.
4. Explain any four aggregate functions with example.
5. Create simple and composite index. Write command to drop above index.
6. Write and Explain the syntax for creating and dropping indexes with an example.
7. State the use of group by and order by clauses
8. Write syntax for i) Create Index ii) Drop Index
Q: Important Question.(Marks 6)
1.Consider the following schema Depositor (ACC_no, Name, PAN, Balance)
I) Create a view on Depositor having attributes (ACC_no, PAN) where balance is
greater than
100000.
Ans: create view v1 as select ACC_No,PAN from Depositor where balance >
100000;
2.Create a sequence.
i) Sequence name is Seq _ 1, Start with 1, increment by 1, minimum value 1,
maximum value 20.
Ans: create sequence Seq_1 start with 1 increment by 1 minvalue 1 maxvalue 20;

ii) Use a seq_1 to insert the values into table Student (ID Number (10), Name char
(20));
Ans : insert into student values(Seq_1.nextval,’ABC’);
Unit 3: Interactive SQL and Advance SQL: SQL Performance Tuning

iii) Change the seq_ 1 max value 20 to 50.


Ans : Alter sequence Seq_1 maxvalue 50;
iv) Drop the sequence.
Ans : Drop sequence Seq_1;
3.i) Write a command to create table student (RNo., name, marks, dept.) with proper
datatype
and RNo as primary key.
Ans : Create table student (RNo int primary key,name varchar(20), marks int, dept
varchar(20));
(ii) Write a command to create and drop sequence.
4. Write the SQL queries for following EMP table
Emp(empno,deptno,ename,salary,designation, city.)
i) Display average salary of all employees.
Ans: select avg(salary) from emp;
ii) Display names of employees who stay in Mumbai or Pune.
Ans: select ename from emp where city=’Mumbai’ or city=’Pune’;
iii) Set the salary of employee 'Ramesh' to 50000.
Ans : update emp set salary=50000 where ename=’Ramesh’;
iv) Display names of employees whose salaries are less than 50000.
Ans: select ename from emp where salary<50000;
v) Remove the Record of employees whose deptno is 10.
Ans : delete from emp where deptno=10;
vi) Remove the column deptno from EMP table.
Ans : alter table emp drop column deptno;
5.Write and Explain the syntax for creating, Altering and dropping the sequence.
6.Consider the schema Customer (Cust-id, Cust_name, Cust_addr, Cust_city)
i) Create a view on Customer (Cust_id, Cust_name) where Cust_city is ‘Pune’ .
Ans: Create view V1 as select Cust_id,Cust_name,Cust_addr,Cust_city from
Customer.
ii) Create a sequence on Cust_id.
Ans:CREATE SEQUENCE Cust_id
start with 1
Unit 3: Interactive SQL and Advance SQL: SQL Performance Tuning

increment by 1
minvalue 0
maxvalue 100
cycle;

7. Consider following schema:


1. 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.
Ans: select ename,empno from EMP order by salary desc;
(ii) Display employee name & employee number whose designation is Manager.
Ans : select ename,empno from EMP where designation=‟Manager‟;
(iii) Display total salary of all employees.
Ans : select sum(salary) from EMP;
(iv) Display employee names having deptno as 20 and dept_location is Mumbai
Ans : select enamefrom EMP where deptno=20 and dept_location=‟Mumbai‟;
(v) Display name of employee who earned lowest salary.
Ans : select ename from EMP where salary=(select min(salary) from EMP);

You might also like