Skip to main content

Oracle Database Programming MCQs with Answers

Practice important Oracle Database Programming MCQs with answers and explanations.

Chapter: 5
Q81:
Which of the following will declare a constant in PL/SQL?
A. cost number := 100;
B. PI CONSTANT NUMBER := 3.14;
C. value integer := 20;
D. fixed_value real := 30.5;
Correct Answer: B
Chapter: 6
Q82:
What is the purpose of the SELECT INTO statement in PL/SQL?
A. To insert values into a table
B. To retrieve data from a table and assign to variables
C. To update values in a table
D. To delete rows from a table
Correct Answer: B
Chapter: 6
Q83:
What exception is raised if the SELECT INTO statement returns more than one row?
A. TOO_FEW_ROWS
B. TOO_MANY_ROWS
C. NO_ROWS_FOUND
D. SYNTAX_ERROR
Correct Answer: B
Chapter: 6
Q84:
In the SELECT INTO syntax, what condition must the WHERE clause satisfy?
A. It must return all rows
B. It must return exactly two rows
C. It must return at most one row
D. It must return more than one row
Correct Answer: C
Chapter: 6
Q85:
What is the output of the statement SELECT 4982, sysdate INTO id, current_date FROM dual?
A. 4982 and current date
B. 1234 and current time
C. 6789 and previous date
D. None of the above
Correct Answer: A
Chapter: 6
Q86:
What happens if a SELECT INTO query tries to fetch multiple rows without a WHERE clause?
A. Returns all rows
B. An exception is raised
C. Returns the first row
D. Only the last row is fetched
Correct Answer: B
Chapter: 6
Q87:
What is the result of the PL/SQL block that selects empno, ename, hiredate INTO id, name, date_hire FROM emp WHERE empno=7369?
A. Error due to multiple rows
B. Values for empno 7369 are retrieved
C. Values for empno 1234 are retrieved
D. No data found
Correct Answer: B
Chapter: 6
Q88:
What is the condition used to select employees with more than 5 years in an organization?
A. deptno != 10
B. hiredate >= 60 months
C. months_between(sysdate, hiredate) >= 60
D. hiredate = sysdate
Correct Answer: C
Chapter: 6
Q89:
Which DML command is used to add rows to an existing table?
A. INSERT
B. UPDATE
C. DELETE
D. SELECT
Correct Answer: A
Chapter: 6
Q90:
What is the output when the salary of employee no 7369 is increased by 25% of the maximum salary in the PL/SQL block?
A. Old salary: 60000, New salary: 75000
B. Old salary: 67589.6, New salary: 84487
C. Old salary: 50000, New salary: 60000
D. Old salary: 65000, New salary: 80000
Correct Answer: B
Chapter: 6
Q91:
In PL/SQL, how is a unique sequence generated?
A. Using a SELECT statement
B. Using a COMMIT statement
C. Using a ROLLBACK statement
D. Using a sequence object
Correct Answer: D
Chapter: 6
Q92:
What command is used to save a transaction in PL/SQL?
A. SAVEPOINT
B. ROLLBACK
C. COMMIT
D. SELECT
Correct Answer: C
Chapter: 6
Q93:
In a PL/SQL block, which command is used to undo a transaction?
A. SAVEPOINT
B. ROLLBACK
C. COMMIT
D. INSERT
Correct Answer: B
Chapter: 6
Q94:
What is the purpose of SAVEPOINT in a transaction?
A. To save the entire transaction
B. To roll back the entire transaction
C. To mark a point in the transaction to roll back to
D. To commit the transaction
Correct Answer: C
Chapter: 6
Q95:
What will the output be if a ROLLBACK to SAVEPOINT A occurs after two rows were inserted in a table?
A. 2 rows inserted
B. 1 row inserted
C. 0 rows inserted
D. Error
Correct Answer: B
Chapter: 7
Q96:
What does the IF-THEN statement in PL/SQL do?
A. Executes the statements if condition is TRUE
B. Executes statements if condition is FALSE
C. Loops through all conditions
D. Skips the statement
Correct Answer: A
Chapter: 7
Q97:
In PL/SQL, which keyword is used to end an IF statement?
A. FINISH
B. END IF
C. TERMINATE
D. CLOSE
Correct Answer: B
Chapter: 7
Q98:
What is the maximum number of employees allowed in any department according to the policy mentioned?
A. 50
B. 60
C. 40
D. 70
Correct Answer: A
Chapter: 7
Q99:
In the provided PL/SQL block, which table is being checked for department #20 employee count?
A. sales
B. emp
C. accounts
D. hr
Correct Answer: B
Chapter: 7
Q100:
Which of the following represents the output of the program where the total employees are less than or equal to 50?
A. "Table is empty"
B. "Table is not empty"
C. "Row inserted in Department 20"
D. "Row could not be inserted"
Correct Answer: B

Test Your Knowledge

Take a timed quiz on Oracle Database Programming

🚀 Start Quiz Now