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

DMA Solvedqb

Uploaded by

tomido1909
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)
176 views

DMA Solvedqb

Uploaded by

tomido1909
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/ 18

DMA Chapter wise Question Bank –CT2

Chapter 3
1. Define index. Explain types of indices with proper example.

Index:
• It is database object used to speed up performance of queries.
• It can be created or dropped with no effect on data.
• There are three types of index:
1. Simple Index:
It is created on one column.
Syntax:
create index index name on table name ( column name);
Example:
Create index i1 on emp(eid);

2. Unique Index:
Unique index does not allow duplicate values.
Syntax:
create unique index indexname on tablename (columnname);
Example:
Create unique index i2 on emp(phone);

3. Composite Index:
A composite index is created on two or more columns.
Syntax:
Create index indexname on tablename (columnname1, columnname2);
Example:
Create index i3 on emp(eid, ename);

2. Define Synonym .Write syntax and example of create and drop synonym.

It is alternative name for database object such as tables, views, sequences etc.

Creating Synonym:

Syntax:

Create synonym <synonymname> for tablename;


Example:

Create synonym st for studentinfo;

Dropping Synonym:

Syntax:

Drop synonym synonymname;

Example:

Drop synonym st;

3. Create synonyms for class table.

4. Create Synonym emp for employee. (iii) Drop Synonym created on employee
table.

Create synonym emp for employee;

Output:

Synonym created.

Drop synonym emp;


Output:

Synonym dropped.

Chapter 4
5. Enlist types of exceptions in PL/SQL.

System defined exception (Predefined exceptions)- They are executed when any
database rule is violated by a program.

User-defined exceptions - PL/SQL allows you to define your own exceptions according
to the need of your program.

6.Write a PL/SQL code to raise zero_divide exception, in case of division of a


number by another.

System-defined:

User-defined:
7. Define Cursor .List its types.

• A cursor is a pointer to this context area.


• PL/SQL controls the context area through a cursor.
• A cursor holds the rows (one or more) returned by a SQL statement.
• The set of rows the cursor holds is referred to as the active set.
• There are two types of cursors − 1. Implicit cursors 2. Explicit cursors
8. Define Trigger . List types of triggers.

Trigger: : A trigger is a stored procedure in database which automatically invokes


whenever a special event in the database occurs. For example, a trigger can be invoked
when a row is inserted into a specified table or when certain table columns are being
updated.

Types of triggers:
• Row level trigger
• Statement level trigger
• After Trigger
• Before trigger
9 Differentiate between PL/SQL function and procedure. (any four differences).

10. Draw and explain PL/SQL block structure.

PL/SQL stands for procedural language extension to SQL.


Declaration section:
• Variables are declared here.
• This is an optional block.

Begin Section:
• We write SQL and PL/SQL executable statements in this block.
• This is compulsory block.

Exception Handling Section:


• It contains error handling statements.
• This is an optional block.

End:
• It indicates the termination of the code.
• This is compulsory block.
11. State any two advantages of PL/SQL.
• PL/SQL is integrated with SQL.
• PL/SQL allows sending entire block of statement to database at one time this
provides high performance.
• Applications written in PL/SQL are fully portable.
• PL/SQL provides high security level.

12.List any four statements of PL/SQL.

• Character datatype.
• Number datatype.
• Boolean datatype
• Date datatype
• LOB datatype

13. With suitable example write steps to create triggers and drop a trigger.

Syntax to drop trigger:

Drop trigger trigger name;


14.Write PL/SQL code using user defined exception for following scenario. If salary
of employee is greater than 20,000 after giving raise by 20% then raise exception
stating, “Salary too high”.

15. Write PL/SQL program to display odd numbers between 1 to 50.

16. List the types of triggers. Write the steps to create trigger with example.
Types of trigger:

• Row level trigger


• Statement level trigger
• Before trigger
• After trigger

Steps to create trigger:


Refer qts 13

17.Create cursor emp_copy to select all records from employee table and copy
them into employee2 table.

create table t1(


id int primary key,
name varchar2(20)
);

insert all
into t1 values(1,'a')
into t1 values(2,'b')
select 1 from dual;

create table t2(


id2 int primary key,
name2 varchar2(20)
);
declare
c_id t1.id%type;
c_name t1.name%type;
cursor c is
select id,name from t1;
begin
open c;
loop
fetch c into c_id,c_name;
exit when c%notfound;
insert into t2 values(c_id,c_name);
end loop;
close c;
end;

18.Create a trigger which invokes on updating of record on emp table.

19.Write a PL/SQL code to find sum of numbers from 1 to 20.


20.Explain Procedure ,how to create execute and delete it.
Chapter 5
21.Define database backup. Describe how database backup helps to avoid failures.
In case, any kind of failure strikes your SQL server databases, a proper plan and a way of
recovery from that failure is needed, beforehand. A good backup can indeed be the best
way to recover from most of the failures, especially when your data is too critical or
important. In case, you lose a database or any of the table becomes corrupt, then you can
simply reload your data from the backup. In addition, if you lose the whole server, then
you may need to set up a new server and re-install the SQL Server backup software,
before using any of your backups.

22.Describe ACID properties of Transaction.

23.Enlist different types of database users.


24.Describe types and causes of failure in database environment.

25.Draw diagram of transaction and explain


26. Describe system and object privileges and also describe use of Grant and
Revoke commands with suitable example.

27.Consider schema ‘employee’ created by ‘user1’ Write SQL queries for following :
i) Grant ‘select’ and ‘insert’ permissions to user2. ii) Assign all privileges for the
user user3. iii) Remove ‘select’ permission from user2 for t able ‘employee’. iv)
Grant ‘update’ permission to user2 and user3 v) Remove all permission from user3
28. Explain lock based concurrency control algorithm.

29.Write SQL statements for following.


(i) Create user ‘admin’ with password ‘123’

Create user admin identified by 123;

(ii) Give user admin full access to employee table.

Grant all privileges to admin;

(iii) Remove delete privileges from admin.

Revoke delete from admin;

30. Describe GRANT and Revoke with its syntax and example.

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