MCQ SQL PLSQL - 80 MCQs For Qualifier
MCQ SQL PLSQL - 80 MCQs For Qualifier
An Instance consists of
Oracle Architecture
Oracle Architecture
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;
/
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
Which of the following can replace
the below query?
SELECT name, course_id
Oracle
FROM instructor, teaches
WHERE instructor_ID=
teaches_ID;
PLSQL
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 Variable
The correct syntax to declare
PL/SQL variable is –
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?
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;
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
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
P AND Q
A. Where
Insert
Committed Transaction
Collection
Integer
For Loop
sysdate
Group by Clause
too_many_rows
Sub Query
Functions
Functions
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
BROWNING<=====>
7
PROCEDURES
CONTINUE WHEN
%ROWTYPE
DEFAULT
DROP PROCEDURE
complex set
no_data_found
WHEN OTHERS
TOO_MANY_ROWS
4
procedure implementation
d_count
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
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
FALSE
FALSE
FALSE
no
scope=memory scope=both
Physical container for a segment physically
contiguous blocks
2 4
varchar char
Arithmetic Number
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
2 0
FALSE
FALSE
Functions Triggers
Autonomous
Rolled Back Transaction
Transaction
Table Index
Procedures Triggers
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
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
no_data_found divide_by_zero
Procedures Triggers
invalid_number Invalid_cursor
"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
IN OUT 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’);
NULL values are returned for the columns from the right table
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
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
none No_Data_Found
B Difficult
B Medium
<=====>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
Medium
NO EXCEPTION NO_DATA_FOUND
D
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
Medium
FLOAT BOOLEAN B
Medium
Medium
Medium
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
Medium