0% found this document useful (0 votes)
8 views7 pages

Answers DMS

The document contains a series of questions and answers related to SQL and PL/SQL, covering topics such as aggregate functions, string functions, database failures, and the role of a database administrator. It also includes examples of triggers, PL/SQL programs, cursor implementation, SQL queries for sequence management, and the structure of PL/SQL blocks. Additionally, it explains the states of transactions and provides a brief mention of data warehousing and MongoDB.

Uploaded by

tanmayambi88
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)
8 views7 pages

Answers DMS

The document contains a series of questions and answers related to SQL and PL/SQL, covering topics such as aggregate functions, string functions, database failures, and the role of a database administrator. It also includes examples of triggers, PL/SQL programs, cursor implementation, SQL queries for sequence management, and the structure of PL/SQL blocks. Additionally, it explains the states of transactions and provides a brief mention of data warehousing and MongoDB.

Uploaded by

tanmayambi88
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/ 7

2 Marks Questions.

Q.1 Enlist any four aggregate functions.


1.avg()
2.sum()
3.max()
4.min()
5.count()
---------------------------------------------------------------------------------------------------------------

Q.2 Enlist any two string functions with examples.


1. Lower(char)- Returns the input string with all letters in lower case.
Example: SQL>Select lower (‘RAJESH’) from dual;
Output: rajesh
2. Upper(char)- Returns the input string with all letters in upper case.
Example: SQL>Select upper (‘rajesh’) from dual; Output: RAJESH
3. Ltrim(char,set)- It removes or trims from left of character string Example:
SQL>Select Ltrim(‘university’,’univ’) from dual; Output: ersity
4. Rtrim(char,set)- It removes or trims from right of character string.
Example: SQL>Select Rtrim(‘university’,’sity’) from dual; Output: univer
---------------------------------------------------------------------------------------------------------------

Q.3 Difference between stored procedure and stored function.


Q.4 List four advantages of PL/SQL.
 1) Portability: PL/SQL applications can run on any operating system and other
platforms supported by Oracle databases without any changes.

 Performance: PL/SQL improves performance by adding procedural processing


power to Oracle tools.

 Productivity: PL/SQL lets you write compact code for manipulating data.

 Tight integration with SQL: PL/SQL is tightly integrated with SQL, the standard
database language.
---------------------------------------------------------------------------------------------------------------

Q.5 State any four causes of database failure


1)power failure
2)human error
3)disk failure
4)software corruption
5)natural disasters.
---------------------------------------------------------------------------------------------------------------

Q.6 Enlist role of database administrator.


1)decide hardware
2)manages data integrity and security
3)data accessibility.
4)installing the DBMS servers.
5)backup and recovery
6)designing and implementation.
---------------------------------------------------------------------------------------------------------------

Q.7 State the types of database users.


1)naïve user
2)sophisticated user
3)application user
4)specialized user
---------------------------------------------------------------------------------------------------------------
Q.8 Enlist any four numeric functions with example.
1)ABS(): It returns the absolute value of a number.
Example-select abs(-5) from dual;
Output-5
2) POWER(m, n): It returns m raised to the nth power.
Example-select power(4,2) from dual;
Output-16
3) SQRT(): It returns the square root of a number.
Example-select SQRT(16) from dual;
Output-4
4) MOD(): It returns the remainder of m divided by n.
Example-select mod(18,4) from dual;
Output-2
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------

4 Marks Questions
Q.1 Write a trigger which invokes on deletion of record on emp table.
Create or replace trigger deletion_trigger before delete on emp
For each row
Begin
Raise_application_error(-20000,’can’t delete record’);
End;
---------------------------------------------------------------------------------------------------------------

Q.2 Write PL/SQL program to check whether specified employee present


in EMP table or not.Accept empno from user.if employee does not exit
display message using exception handling.
Set serveroutput on;
Declare
E_id EMP.empno%type:=&E_id;
Begin
Select empno into E_id from EMP where empno=E_id;
Dbms_output.put_line(‘Employee is presnt with entered id ‘|| E_id);
Exception
When no_data_found then
Dbms_output.put_line(‘employee is not present in table’);
End;
---------------------------------------------------------------------------------------------------------------

Q.3 Explain steps of cursor implementation with example.


A cursor holds the rows (one or more) returned by a SQL statement.

Declaring:

This term is used to declare a cursor so that memory initialization will take place.

A cursor is declared by defining the SQL statement that returns a result set.

Opening: A Cursor is opened and populates data by executing the SQL statement defined by
the cursor.

Fetching: Rows are retrieved from the Cursor using the FETCH statement, which moves the
Cursor to the next row in the result set and makes the row’s data available for processing.

PROCESS THE FETCHED ROW: The data of the fetched row can be processed using the
variable name.

Closing a Cursor: This forces cursor for releasing the allocated memory assigned/ occupied
by cursor.

Example of cursor :

DECLARE

cursor emp_cursor IS SELECT * FROM employees;

emp_record employees%ROWTYPE;

BEGIN

OPEN emp_cursor;

LOOP
FETCH emp_cursor INTO emp_record;

EXIT WHEN emp_cursor%NOTFOUND;

--process the fetched row

dbms_output.put_line(emp_record.first_name || ' ' || emp_record.last_name);

END LOOP;

CLOSE emp_cursor;

END;
---------------------------------------------------------------------------------------------------------------

Q.4 Write SQL queries for following.


1. Sequence name is Seq_1,start with 1,increment by1,minimum value 1,maximum
value 20.
Create sequence Seq_1 start with 1 increment by 1 minvalue 1 maxvalue 20;
2. Use Seq_1 to insert the values into table Student(ID number(10),Name
char(20));
Insert into student values(Seq_1.nextval,’ABC’);
3. Change the Seq_1 max value from 20 to 50.
Alter sequence Seq_1 maxvalue 50;
4. Drop the sequence.
Drop sequence Seq_1;
---------------------------------------------------------------------------------------------------------------

Q.5 Explain PL/SQL Block Structure.


Explanation of PL/SQL Block Structure:

 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.


---------------------------------------------------------------------------------------------------------------

Q.6 Explain states of transaction with diagram.

 Active − This is the state in which a transaction is being executed. Thus, it is like the
initial state of any given transaction.
 Partially Committed − A transaction is in its partially committed state whenever it
executes the final operation.
 Failed − In case any check made by a database recovery system fails, then that
transaction is in a failed state. Remember that a failed transaction can not proceed
further.
 Aborted − In case any check fails, leading the transaction to a failed state, the
recovery manager then rolls all its write operations back on the database so that it can
bring the DB (database) back to the original state (the state where it actually was prior
to the transaction execution). The transactions in this state are known to be aborted. A
DB recovery module can actually select one of these two operations after the abortion
of a transaction –

 Re-start
 Kill the transaction
 Committed − We can say that a transaction is committed in case it actually executes
all of its operations successfully. In such a case, all of its effects are now established
permanently on the DB system.
---------------------------------------------------------------------------------------------------------------

Q.7 Explain following concept:-


1)Data Warehouse 2)MongoDB
1)DatawareHouse
-for this concept refer notes of chapter 5
---------------------------------------------------------------------------------------------------------------

You might also like