DMA Model Answer
DMA Model Answer
DMA Model Answer
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 1 / 15
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 2 / 15
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Use:
Synonyms are used mainly to make it easy for users to access
database objects owned by other users. They hide the underlying
object's identity and make it harder for a malicious program or user to
target the underlying object.
Page 3 / 15
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 4 / 15
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 5 / 15
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Example: -
Example: -
SELECT * FROM `movies` GROUP BY
`category_id`,`year_released` HAVING `category_id` = 8;
d) Create a sequence for the following specification. 4M
Ans. Name ABC, Starting value: 10, Maximum value: 100,
Correct
Increment by 10. logic 2M
Create Sequence ABC
Start with 10 Correct
syntax 2M
Increment by 10
Minvalue 10
Maxvalue 100;
Note: Any other relevant code can be considered
Page 6 / 15
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
In PL/SQL, you can refer to the most recent implicit cursor as the
SQL cursor, which always has attributes such as %FOUND,
%ISOPEN, %NOTFOUND, and %ROWCOUNT. The SQL
cursor has additional attributes, %BULK_ROWCOUNT and
%BULK_EXCEPTIONS, designed for use with the FORALL
statement. Example: -
The following program will update the table and increase the salary
of each customer by 500 and use the SQL%ROWCOUNT attribute
to determine the number of rows affected −
DECLARE
total_rows number(2);
BEGIN
UPDATE customers
SET salary = salary + 500;
IF sql%notfound THEN
dbms_output.put_line('no customers selected');
ELSIF sql%found THEN total_rows:= sql
%rowcount;
dbms_output.put_line( total_rows|| ' customers selected ');
END IF;
END;
/
Explicit cursors are programmer-defined cursors for gaining more
Descriptio
control over the context area. An explicit cursor should be defined n of
in the declaration section of the PL/SQL Block. It is created on a Explicit
cursor 2M
SELECT Statement which returns more than one row.
Page 7 / 15
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 8 / 15
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Creating an Index:
Correct
Syntax: command
CREATE INDEX index to create
ON TABLE column; Index 2M
where the index is the name given to that index and TABLE is the
name of the table on which that index is created and column is the
name of that column for which it is applied.
Note: Any other relevant example shall be considered
c) Consider the Schema Emp (E.NO, E. Name, Department, Salary, 4M
Bonus). Write SQL command for the following.
i) Insert one record with suitable data.
ii) Display all records having a salary between 5000 and 10000.
iii) Get the total salary of all the employees.
iv) Display E.No., E.Name and total payment (i.e. Salary and
Bonus) of all employees.
Each
Ans. i) insert into Emp (E.NO, E.Name, Department, Salary, Bonus) correct
values (001,"Amit","Sales",20000,3000); command
1M
OR i) insert into Empvalues (001,"Amit","Sales",20000,3000);
ii) select * from Emp where Salary between 5000 and 10000;
iii) select sum(Salary) from Emp;
iv) select E.NO, E.Name, Salary, Bonus from Emp;
Page 9 / 15
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Diagram
2M
Page 10 / 15
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
6. Terminated State –
If there isn‟t any roll-back or the transaction comes from the
“committed state”, then the system is consistent and ready for new
transaction and the old transaction is terminated.
e) Write a PL/SQL program to find the largest of three numbers. 4M
Ans. declare
Correct
a number; logic 2M
b number;
c number; Correct
syntax 2M
begin
dbms_output.put_line('Enter a:');
a:=&a;
dbms_output.put_line('Enter b:');
b:=&b;
dbms_output.put_line('Enter c:');
c:=&C;
if (a>b) and (a>c)
thendbms_output.put_line('A is GREATEST'||A);
elsif (b>a) and (b>c)
then
dbms_output.put_line('B is GREATEST'||B);
else
dbms_output.put_line('C is GREATEST'||C);
end if;
end;
Note: Any other relevant program shall be considered.
5. Attempt any TWO of the following: 12
a) Consider the schema 6M
Department (DNO, D Name, Location, Manager), Write SQL
commands for the following:
i) Create department table with suitable data type and size of
each attribute.
ii) Add one more attribute as Ph-no with suitable data type.
iii) Add the constraint primary key to D No.
Page 11 / 15
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Ans. i)
create table Department
(
DNO number(5),
DName varchar2(25), Each
Location varchar2(20), correct
Manager varchar2(30) command
2M
);
Page 12 / 15
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
b) 6M
Page 13 / 15
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
(OR)
select * from Product where Price>2000;
Page 14 / 15
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Function Calling
begin
dbms_output.put_line(circle_area(3));
end;
/
(OR)
SQL>declare
r number;
ans number;
begin
r:=&r;
ans:=circle_area(r);
dbms_output.put_line(“radius=”||r);
dbms_output.put_line(“Area of circle ="||ans);
end;
/
ii)
create or replace procedure Greet_User (user_name in varchar2) Correct
is Procedure
begin logic and
syntax 3M
dbms_output.put_line(„Greet „ || user_name);
end;
/
Page 15 / 15