0% found this document useful (0 votes)
63 views44 pages

MCQ SQL PLSQL - 80 MCQs For Qualifier

The document discusses various Oracle architecture and PL/SQL topics. It covers concepts like Oracle architecture components, data blocks, parameter files, PL/SQL blocks, loops, variables, datatypes, exceptions, procedures and more. Questions are provided for each topic to test understanding.

Uploaded by

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

MCQ SQL PLSQL - 80 MCQs For Qualifier

The document discusses various Oracle architecture and PL/SQL topics. It covers concepts like Oracle architecture components, data blocks, parameter files, PL/SQL blocks, loops, variables, datatypes, exceptions, procedures and more. Questions are provided for each topic to test understanding.

Uploaded by

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

Topic Sub-Topics Questions

An Instance consists of

Oracle Architecture

An Oracle Server consists of


Oracle Architecture
Pfile and spfile are parameter files

Oracle Architecture

Oracle Architecture spfile is the text file


Oracle Architecture pfile is the text file
When you want to change the
parameter in Database using pfile,
Oracle Architecture do you have to shutdown the
database?

Oracle Architecture for a particular session , we want to


What is a data block?
Oracle Architecture

PLSQL The Number of sections in a PLSQL


Oracle Block is
PLSQL What error do you get in the below
block?
DECLARE
c VARCHAR2(3 CHAR);
BEGIN
Oracle c := 'xyz ';
END;
/

PLSQL The size of "----------------" datatype


cannot be extended beyond the
Oracle definition of that datatype

PLSQL The PLSQL "-----------" datatype


Oracle stores true and false logical values
PLSQL Which are the loop statement used
Oracle in PLSQL?
PLSQL What is the output of the
following code?
DECLARE
grade CHAR(1);
BEGIN
grade := 'D';

CASE grade
WHEN 'A' THEN
DBMS_OUTPUT.PUT_LINE('Excelle
nt');
WHEN 'B' THEN
DBMS_OUTPUT.PUT_LINE('Very
Good');
WHEN 'C' THEN
DBMS_OUTPUT.PUT_LINE('Good');
WHEN 'D' THEN
DBMS_OUTPUT.PUT_LINE('Fair');
Oracle WHEN 'F' THEN
DBMS_OUTPUT.PUT_LINE('Poor');
ELSE
DBMS_OUTPUT.PUT_LINE('No
such grade');
END CASE;
END;
/

PLSQL The "----------------------" statement


exits the current iteration of a loop
when the condition in
Oracle its WHEN clause is true

PLSQL The Exception Handler returns


Oracle the control to the invoker if it is in a
"--------------------"
PLSQL What output , do you receive for the
following code?

DECLARE
PROCEDURE p (fees NUMBER)
IS
discount NUMBER := 0;
BEGIN
IF fees > 50000 THEN
discount := 1500;
ELSIF fees > 35000 THEN
discount := 500;
ELSE
discount := 100;
END IF;

DBMS_OUTPUT.PUT_LINE (
Oracle 'Fees = ' || fees || ', discount = '
|| discount || '.'
);
END p;
BEGIN
p(55000);
p(40000);
p(30000);
END;
/

PLSQL A "--------------" stores same


Oracle datatype
PLSQL PLSQL Exceptions are
Oracle
PLSQL Predefined Exception can also be
Oracle called as

PLSQL How the elements of PLSQL


Oracle Collection are accessed
PLSQL The lower bound of a varray index is
Oracle
PLSQL UnionAll operator removes
Oracle duplicates from oracle result set
Oracle PLSQL The Union Operator after applied on
PLSQL A Package can embed which of the
Oracle
following?
PLSQL
Oracle A Pragma is used in
Oracle PLSQL Associative Array is an example of
PLSQL Tool used for interfacing with
Oracle RDBMS is
PLSQL Tools describing data,data
Oracle relationship and constraint are
SQL

Difference between Delete and


Oracle
Truncate Commands is

PLSQL
Which of the following can replace
the below query?
SELECT name, course_id
Oracle
FROM instructor, teaches
WHERE instructor_ID=
teaches_ID;

PLSQL

Which of the following statements


are TRUE about an SQL query?
P: An SQL query can contain a
HAVING clause even if it does not
have a GROUP BY
clause
Q: An SQL query can contain a
HAVING clause only if it has a
Oracle
GROUP BY clause
R: All attributes used in the GROUP
BY clause must appear in the SELECT
clause
S: Not all attributes used in the
GROUP BY clause need to appear in
the SELECT clause

Oracle PLSQL In an SQL statement, which of the fol


Oracle PLSQL A command that lets you change one or
PLSQL
Oracle A Pragma is used in
Oracle PLSQL Associative Array is an example of
Oracle PLSQL LONG RAW is used for storing
Oracle PLSQL Exit When is used in
PLSQL select systimestamp from dual?
Oracle
Returns what?
PLSQL
select ename,sum(salary) from emp
Oracle group by ename having salary>5000;
Having can be used along with

PLSQL exception
when no_data_found then
Oracle
dbms_output.put_line(‘The Query
does not retrieve records’);
PLSQL
SELECT
product_id,
product_name,
list_price
FROM
products
WHERE
Oracle
list_price =(
SELECT
MIN( list_price )
FROM
products
);
This is an example of

PLSQL This Sub-Program can have IN,OUT


Oracle and IN OUT Parameters , while
calling
PLSQL This Sub-Program must return value
Oracle
to the main program
PLSQL
Oracle Exception

Oracle PLSQL Which Statement is/are true


Oracle PLSQL % rowtype specifies the
SQL
SELECT
ord_num,ord_amount,ord_date,
cust_code, agent_code FROM orders
Oracle WHERE agent_code IN( SELECT
agent_code FROM agents WHERE
working_area='Bangalore'); if
subquery returns single row then

SQL SELECT LTRIM('<=====>BROWNING<=====>', '<>=') "LTRIM Example"


Oracle
FROM DUAL; returns
SQL SELECT LENGTH('CANDIDATE')
Oracle "Length in characters"
FROM DUAL; returns

PLSQL Variable
The correct syntax to declare
PL/SQL variable is –

____ are values used in PL/SQL


PLSQL Variable blocks that do not change during
execution.

What is wrong in the following


code snippet?
DECLARE
x number := 1;
BEGIN
LOOP
dbms_output.put_line(x);
PLSQL LOOPS
x := x + 1;
IF x > 10 THEN
exit;
END IF;
dbms_output.put_line('After
Exit x is: ' || x);
END;
DECLARE
a number;
b number;
c number;

PROCEDURE findMin(x IN
number, y IN number, z OUT
number) IS
BEGIN
IF x < y THEN
z:= x;
PLSQL PROCEDURES ELSE
z:= y;
END IF;
END;

BEGIN
a:= 2;
b:= 5;
findMin(a, b, c);
dbms_output.put_line(c);
END;
What will be the output?

Which of the following


PLSQL loops statements can be used to
terminate a PL/SQL loop?
PLSQL TYPES
Which of the following is used to declare a

PLSQL PROCEDURES What is the default mode of parameters


in procedures?

PLSQL PROCEDURES A standalone procedure is deleted with


the ________ statement?

PLSQL CURSOR The set of rows the cursor holds is


referred to as the __________.
If we try to open the cursor which is
PLSQL CURSOR already closed which runtime error will
be raised?

PLSQL EXCEPTION HANDLING


How to handle catch all exceptions?
delete from product where
pid=2;
begin
PLSQL EXCEPTION HANDLING select * from product where
pid=2;
end;
which exception will be raised?
declare
num1 number(2):=&num1;
num2 number(2):=&num2;
begin
PLSQL EXCEPTION HANDLING
select num1/num2 from dual;
end;
/
enter value for num1=4
enter value for num2=0
what will be the output?
What cannot be written in
PLSQL PACKAGES
package spacification?

Consider the following


procedure:
Create procedure
dept_count( dept_name IN
varchar(20),d_count OUT
integer)
begin
PLSQL PROCEDURES select count(*) into d_count from
instructor where deptName =
dept_name;
end;
/

This procedure returns the result


using which parameter?

Create procedure
dept_count_proc(in dept_name
varchar(20),d_count out
integer)
begin
select count(*) into d_count
PLSQL PROCEDURES from instructor
where instructor.dept_name=
dept_count _proc.dept_ name
end;
/
Which of the following is used to
call the procedure given above ?
A stored procedure in SQL is
a___________

PLSQL PROCEDURES

DECLARE
v_salary NUMBER := 5000;
BEGIN
IF v_salary > 10000 THEN

DBMS_OUTPUT.PUT_LINE('Hi
PLSQL Conditions gh Salary');
ELSE

DBMS_OUTPUT.PUT_LINE('Lo
w Salary');
END IF;
END;What will be the output

CREATE OR REPLACE
PROCEDURE
update_employee_salary (
p_employee_id NUMBER,
p_new_salary NUMBER
)
IS
BEGIN
UPDATE employees
SET salary = p_new_salary
WHERE employee_id =
p_employee_id;

PLSQL PROCEDURES COMMIT;

DBMS_OUTPUT.PUT_LINE('E
mployee salary updated
successfully.');
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;

DBMS_OUTPUT.PUT_LINE('Err
or occurred: ' || SQLERRM);
END;
/ WHAT THIS CODE WILL DO?
Which of the followimg is not a valid
SQL DATA TYPES SQL data type
Which of the following queries
demonstrates the use of a scalar
subquery?
SQL SUBQUERY

Consider the following SQL query:


sql
SELECT employee_id, last_name
SQL SUBQUERY FROM employees
WHERE department_id = (SELECT
department_id FROM departments
WHERE department_name = 'IT');

This is an example of which type of


subquery?

Consider the following SQL query:


sql
SELECT employees.first_name,
SQL JOINS departments.department_name
FROM employees
INNER JOIN departments ON
employees.department_id =
departments.department_id;

This query performs which type of


join?

Which database object is used


to generate unique numbers?
SQL JOINS What is the result of an SQL
LEFT JOIN when there are no
matching rows in the right table

In SQL, which JOIN type returns all rows


from both tables, combining rows when
the column values match and including
SQL JOINS
unmatched rows from both tables?

What does the SQL statement "DELETE


SQL DML FROM table_name;" do?
What is the purpose of the SQL statement
SQL TCL "ROLLBACK"?
What does the SQL statement "SELECT
SQL DML DISTINCT column_name FROM
table_name;" do?
Which of the following is NOT an
SQL AGGREGATE FUNCTIONS aggregate function in SQL?

Consider the following SQL


query:

sql
Copy code
SQL MULTIROW FUNCTIONS
SELECT customer_id,
SUM(order_total) AS total_spent
FROM orders
GROUP BY customer_id
HAVING total_spent > (SELECT
AVG(order_total) FROM orders);
What does this query return?
Options (A)
Memory Structures and Background Processes

Instance

1
1
Yes

scope=spfile
specific number of bytes on the disk

too_many_rows

varchar2

Boolean

While
Poor

Exit

Named Block
Fees = 55000, discount = 1500.
Fees = 40000, discount = 500.
Fees = 30000, discount = 100.

Record

runtime errors

Internal Exception

variable_name(index)

1
Procedures

Committed Transaction
Collection
SQLPLUS

Schema

A. After the execution of ’TRUNCATE’ operation,


COMMIT, and ROLLBACK statements can be
performed to retrieve the lost data, while ‘DELETE‘ does not allow it.

select name,course_id from instructor natural join teaches

P AND Q

A. Where
Insert
Committed Transaction
Collection
Integer
For Loop
sysdate

Group by Clause

too_many_rows

Sub Query

Functions

Functions

Exception raised while closing an unopened cursor is

The set of rows the cursor holds is referred to as the active set
provides a record type that represents a row in a database table

Will return an error

BROWNING<=====>
7

variable_name [CONSTANT] datatype [NOT NULL] [:= | DEFAULT initial_value]

PROCEDURES

There should be an end loop statement


No output

CONTINUE WHEN

%ROWTYPE

DEFAULT

DROP PROCEDURE

complex set
no_data_found

WHEN OTHERS

TOO_MANY_ROWS
4

procedure implementation

d_count

Declare d_count integer;


Group of functions

High Salary
Inserts a new employee record into the employees table.
INTEGER
Group bySELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);

Scalar subquery

INNER JOIN

An error is thrown

INNER JOIN

Deletes the entire table structure


To save the changes made by the transaction
Returns only unique values from the specified column
COUNT()

The total amount spent by each customer, only including customers whose total spending is greater than the
average order total.
Options (B) Options (C)
Foreground Processes Server process

Instance and Database Database

FALSE

FALSE
FALSE
no

scope=memory scope=both
Physical container for a segment physically
contiguous blocks

2 4

character string buffer too small invalid_cursor

varchar char

Arithmetic Number

Basic Loop For Loop


Excellent Fair

Exit When While

Anonymous Block
Fees = 42000, discount = 2500. Fees = 33000,
Fees = 41000, discount = 400. discount = 1200.
Fees = 23000, discount = 200. Fees = 44000,
discount = 400.
Fees = 20000,
discount = 400.

Collection

runtime warnings compiletime


errors
User-defined Exception Oracle named
exception
handler
variable_name[index] index

2 0

FALSE

FALSE
Functions Triggers

Autonomous
Rolled Back Transaction
Transaction
Table Index
Procedures Triggers

Data Model Objects

C. After the
execution of
’DELETE‘
operation,
COMMIT and
ROLLBACK
B. After the execution of ’DELETE‘ and TRUNCATE' operation
statements can be
retrieval is easily possible for the lost data
performed to
retrieve the lost
data., while
TRUNCATE does
not allow it

select name,course_id from


instructor,teaches where select name,course_
instructor_id=teaches_id

Q AND R P AND S

B. From C. Order By
Modify Look-Up
Autonomous
Rolled Back Transaction
Transaction
Table Index
Float Binary Data
if condition While Loop
time zone

Order by Clause Average

no_data_found divide_by_zero

Correlated SubQuery Both

Trigger Definition Procedures

Procedures Triggers

invalid_number Invalid_cursor

A cursor is a pointer to this context area Implicit cursors ar


type compatibility between table columns and PL/SQL variables type compatibility between table and PL/SQL v

"IN" can be used for multiple values ; which is useful single value in a list "ANY" can be used

<=====>BROWNING BROWNING
14 15

variable_name
[CONSTANT]
datatype [CONSTANT] variable_name [NOT NULL] [:= | DEFAULT
datatype [NULL]
initial_value]
[:= | DEFAULT
initial_value]

FUNCTIONS VARIABLES

The IF
There is nothing wrong statement is not
required
0 5
EXIT WHEN
KILL

%TYPE BOTH A AND B

IN OUT OUT

DELETE PROCEDURE KILL PROCEDURE

simple set inactive set


invalid_cursor more_than_one_row

WHEN DATA_NOT_FOUND WHEN


TRASACTION_BACKE
D_OUT

NO_DATA_FOUND INVALID_CURSOR
ARITHMETIC EXCEPTION NO_DATA_FOUND
variable
procedure header declaration

dept_name deptcount
Declare d_count
integer;
exec dept_count
proc(’Physics’);

Declare d_count integer;


exec dept_count proc(’Physics’, d_count);
Group of distinct SQL statements Block of function

Low Salary error


Deletes an employee record from the employees table. Updates the salary of
an employee
specified by the
employee ID to a
new salary provided
as input.
BOOLEAN DECIMAL
SELECT * FROM employees WHERE department_id IN (SELECT department_id SELECT * FROM
FROM departments WHERE location = 'New York'); employees WHERE
hire_date =
(SELECT
MAX(hire_date)
FROM employees);

Correlated subquery Nested subquery

LEFT JOIN RIGHT JOIN


The query returns
no rows

NULL values are returned for the columns from the right table

LEFT JOIN RIGHT JOIN

Removes specific columns from the table Deletes all rows f


To undo the changes made by the transaction

To commit the ch
Returns all values from the specified column Deletes duplicate
CONCAT() AVG()

The total amount spent by each customer, including all customers regardless of their An error because
total spending. the HAVING clause
cannot refer to an
aggregate function.
Options (D) Correct Answer Correct Option Difficulty Level
user process

Back ground Processes Instance and DatabA


Simple
1 A

Medium

0 B Simple
1 A Simple
Yes

A Medium
None of the Above Scope=Memory B Difficult
All the Above Specific Number of b

A Simple
3 4 C
Medium
None of the Above Character String B
Buffer Too Small

Difficult
string Char C

Medium
string
Boolean
A Simple
All the Above
All the Above
D Medium
Good Fair

C Difficult
Until

Exit

A Medium

Anonymous Block
B Simple
Fees = 35000, Fees = 55000,
discount = 2500. discount = 1500
Fees = 20000,
discount = 200.
Fees = 30000,
discount = 300.

A Medium
Collection
B Medium
compiletime warnings
Runtime Errors
A Medium
None of the Above Oracle Named
Exception
C Simple
variable_name{index} variable_name{ind
ex} D Medium
3 1
A Simple
0
B Medium
1A Medium
All the Above
All the Above
D Simple
Autonomous
None
C Medium
Package Collection A Simple
Package SQLPLUS
A Simple
Entity Data Model
B Medium
After the
execution of
’DELETE‘
operation,
COMMIT and
ROLLBACK
statements can be
D.After the Execution performed to
of DELETE and Truncate retrieve the lost
operation,no retrieval data., while
is possible for the lost TRUNCATE does
data not allow it

C Medium
select
name,course_id
from
instructor,teaches
select course_id from inswhere
instructor_id=teac
hes_id;
B Difficult
Q and R

Q AND S

B Medium
D. Group By Where A Simple
None Modify B Medium
Autonomous
None
C Medium
Package Collection A Simple
Character Binary Data C Simple
if..then..else While Loop C Medium
All the Above
All the Above
D Simple

Sum Group By Clause


A Medium

none No_Data_Found
B Difficult

Either Correlated SubQuer

B Medium

All the Above Procedures


C Medium
All the Above Functions
A Simple
Exception raised
Program_error while closing an
unopened cursor D Medium
All the Above All the Above D Medium
type compatibility between table and indexes

"ALL" can be used if subquery returns one row

<=====>BROWNING<===BROWNING<====
=> A Simple
9 9.00
D Simple
A
datatype variable_name
[CONSTANT] [CONSTANT]
variable_name datatype [NOT Medium
[NULL] [:= | NULL] [:= |
DEFAULT DEFAULT
initial_value] initial_value]
CONSTANTS D
CONSTANTS Medium

There should be
The exit statement should
be in capital letters an end loop Medium
statement
D

Medium

2 2
C
GOTO EXIT WHEN Medium

NONE OF THE A
Medium
ABOVE %ROWTYPE
D
Medium
IN IN
A
Medium
REMOVE PROCEDURE DROP PROCEDURE
active set active set D
Medium
cursor_already_closed invalid_cursor B
Medium

WHEN WHEN OTHERS A


TOO_MANY_ROWS Medium

Medium

NO EXCEPTION NO_DATA_FOUND
D

ZERO_DIVIDE ZERO_DIVIDE Medium

A
Medium
constant declaration procedure implem
A

Medium

EXCEPTION d_count
B

Declare d_count
Declare d_count; integer;
call dept_count exec Medium
proc(’Physics’, dept_count
d_count); proc(’Physics’,
d_count);
Group of D
Group of Transact- Transact-SQL
SQL statements statements Medium
compiled into a compiled into a
single execution plan single execution
plan
b

Medium

no output Low Salary


Retrieves the salary of an Updates the salary of C
employee specified by the an employee
employee ID. specified by the
employee ID to a
new salary provided
as input.

Medium
FLOAT BOOLEAN B
Medium

SELECT * FROM SELECT * FROM C


employees WHERE employees WHERE
employee_id = (SELECT hire_date =
MAX(employee_id) (SELECT Medium
FROM employees); MAX(hire_date)
FROM employees);

Table subquery Correlated subquery B

Medium

Medium

FULL OUTER JOIN INNER JOIN


D
All rows from the
All rows from the left left table are
table are returned returned with
with NULL values NULL values Medium
appended for the appended for
columns from the the columns
right table from the right
table

FULL OUTER
FULL OUTER JOIN Medium
JOIN

C
Medium
Deletes the last row f Deletes all rows f
To restart the transaction To undo the changes B
from the beginning made by the Medium
transaction
Adds a new column to the A
table
Medium
Returns only unique v
SUM() CONCAT() B
Medium

An error because The total amount A


subqueries are not allowed spent by each
in the HAVING clause. customer, only
including customers
whose total spending
is greater than the
average order total.

Medium

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