0% found this document useful (0 votes)
8 views

DMS Short

Uploaded by

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

DMS Short

Uploaded by

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

Q1.

Any Three
b. Write syntax for creating and dropping views.

Ans- CREATE VIEW Syntax:


> create view view name As
select column1, column2 ...
from table name
where condition ;
DROP VIEW Syntax:
DROP VIEW view name;

c. Enlist four aggregate functions.

Ans-> SUM()
AVG()
MAX()
MIN()
COUNT()
d. Define Cursor. List the two types of cursor.

Ans- A cursor is a temporary work area created in the system memory when a SQL
> statement
is executed.
Types of cursor are:
1) Implicit cursor
2) Explicit cursor
Q2 Answer any THREE. (Four marks each)

a.

Ans. 1.Union: Combines results from two SELECT queries, removing duplicates.
Ex. SELECT name FROM Employees
UNION
SELECT name FROM Managers;
2.Union All:Combines results from two SELECT queries, including duplicates.
Ex
1. SELECT name FROM Employees
2. UNION ALL
3. SELECT name FROM Managers;
3.Intersection :Retrieves common records from two SELECT queries.
Ex
1. SELECT name FROM Employees
2. INTERSECT
3. SELECT name FROM Managers;
4.Minus:Retrieves records from the first SELECT query that aren't in the second.
Ex
1. SELECT name FROM Employees
2. MINUS
3. SELECT name FROM Managers;
b. Explain PL/SQL block structure with the help of diagram.

Ans- Explanation of PL/SQL Block Strucure:


> Declaration section
A block begins with declarative section where variables, cursors
are declared. It is an Optional block.
Execution section
Executable SQL or PL/SQL Statements are needed to write here for the execution.
It is mandatory block.
Exception section
It is used to handles the exceptions. It is an Optional block.
End statement
It is used to indicate termination of PL/SQL block. It is mandatory.

c. Describe any four responsibilities of Database Administrator.

Ans- Responsibilities of Database Administrator (DBA):


1. Schema Definition:
Database or schema can be designed or defined by DBA.
2. Creating storage structure:
DBA allocate or decide the space to store the database.
3. Create grant access methods:
Different access methods to access the database can be granted by DBA to the users.
4. Schema modification:
The database or schema which is already defined can be modified by DBA as per the
Q3 Answer any TWO. (SIX marks each)
Write SQL queries for following. 1) Create user named 'user1' having Password '1234
a. ii) Assign 'insert' and update' Privilege to 'userl". ii) Remove update Privilege assigned
to the us

Ans. 1. CREATE USER 'user1' IDENTIFIED BY '1234';


2. GRANT INSERT, UPDATE ON database_name.* TO 'user1';
3. REVOKE UPDATE ON database_name.* FROM 'user1';

c. 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
1. DECLARE
2. c_id NUMBER(10);
3. invalid_id_Exception EXCEPTION;
4. BEGIN
5. c_id := &c_id;
6.
7. IF c_id < 0 THEN
8. RAISE invalid_id_Exception;
9. END IF;
10.
11. EXCEPTION
12. WHEN invalid_id_Exception THEN
13. DBMS_OUTPUT.PUT_LINE('Invalid customer id');
14. END;
15. /
16.

You might also like