Oracle Database Programming MCQs with Answers
Practice important Oracle Database Programming MCQs with answers and explanations.
Chapter: 17
Q241:
In PL/SQL, which attribute is used to check if an element exists in a PL/SQL table?
A. EXISTS
B. COUNT
C. FIRST
D. LAST
Correct Answer:
A
Chapter: 17
Q242:
What does the `COUNT` attribute in PL/SQL tables return?
A. The total number of elements in the table
B. The number of columns in the table
C. The index of the first element
D. The index of the last element
Correct Answer:
A
Chapter: 17
Q243:
Which attribute would you use to remove a specific entry from a PL/SQL table?
A. DELETE
B. COUNT
C. EXISTS
D. FIRST
Correct Answer:
A
Chapter: 17
Q244:
How can you delete all elements in a PL/SQL table?
A. DELETE ALL
B. DELETE
C. DELETE (1, COUNT)
D. DELETE (m, n)
Correct Answer:
B
Chapter: 17
Q245:
In the provided PL/SQL block, how is the `emp_rec` variable used in the INSERT statement?
A. It is inserted into the `emp` table with all its fields
B. It is used to create a new table
C. It modifies an existing table
D. It queries data from the `emp` table
Correct Answer:
A
Chapter: 17
Q246:
What does the `NEXT` attribute in PL/SQL return?
A. The next index number following a given index
B. The number of elements in the table
C. The first element in the table
D. The last element in the table
Correct Answer:
A
Chapter: 17
Q247:
Which PL/SQL block uses the `DELETE` attribute to remove entries from a table?
A. PL/SQL Table and First and Next Attribute
B. PL/SQL Table and Count Attribute
C. PL/SQL Table and Exist Attribute
D. PL/SQL Table and Delete Attribute
Correct Answer:
D
Chapter: 17
Q248:
What does the `EXISTS` function in PL/SQL check?
A. If a specific index exists in the PL/SQL table
B. If an element is at the last position
C. If the table has no elements
D. If the table is empty
Correct Answer:
A
Chapter: 17
Q249:
Which of the following is a correct way to define a User Defined Record in PL/SQL?
A. TYPE <type_name> IS RECORD (<field_name1> <datatype1>, ...);
B. TYPE <type_name> IS ARRAY (<field_name1> <datatype1>, ...);
C. TYPE <type_name> IS TABLE (<field_name1> <datatype1>, ...);
D. TYPE <type_name> IS OBJECT (<field_name1> <datatype1>, ...);
Correct Answer:
A
Chapter: 17
Q250:
What does the PL/SQL block in Implementing User Defined Record – I do?
A. Displays information of the first 5 employees with 'MAN' in their job title
B. Updates employee salaries by 20%
C. Deletes records from the `emp` table
D. Creates a new table with employee details
Correct Answer:
A
Chapter: 17
Q251:
In which PL/SQL block is the cursor `c1` used to update employee salaries?
A. Implementing Cursor -based Records –II
B. Implementing Cursor -based Records –I
C. Implementing User Defined Record –I
D. Implementing User Defined Record –II
Correct Answer:
A
Chapter: 17
Q252:
In the PL/SQL block implementing User Defined Record –II, what action is taken if `emp_rec_val.ename` is 'BLAKE'?
A. The record is inserted into the `history` table
B. The record is updated in the `emp` table
C. The record is deleted from the `emp` table
D. The record is ignored
Correct Answer:
A
Chapter: 17
Q253:
What is the output of the PL/SQL block where the cursor `c1` fetches employee names with a salary less than 3000?
A. Employee names with salaries less than 3000 are displayed
B. Employee names with salaries more than 3000 are displayed
C. No output is generated
D. The program exits without displaying any results
Correct Answer:
A
Chapter: 17
Q254:
When using `FIRST` and `LAST` attributes in PL/SQL, what do they return if the table is empty?
A. Null values
B. First and last elements respectively
C. The number of elements in the table
D. The index of the first element
Correct Answer:
A
Chapter: 18
Q255:
What is a PL/SQL subprogram?
A. A named PL/SQL block that can be invoked with a set of parameters
B. A database table used for storing data
C. A type of database object for storing temporary results
D. A tool for debugging PL/SQL code
Correct Answer:
A
Chapter: 18
Q256:
What does a procedure in PL/SQL primarily do?
A. Store data permanently
B. Perform a specific task or action
C. Define a new table structure
D. Create a temporary view of data
Correct Answer:
B
Chapter: 18
Q257:
Which part of a PL/SQL procedure contains the code that performs the task?
A. Specification
B. Body
C. Declaration
D. Header
Correct Answer:
B
Chapter: 18
Q258:
What does the following PL/SQL statement do? `CREATE OR REPLACE PROCEDURE first_proc AS BEGIN dbms_output.put_line('Hello World!'); END;`
A. Defines a procedure to output 'Hello World!'
B. Defines a function to return 'Hello World!'
C. Creates a table with 'Hello World!' as a value
D. Creates a view with 'Hello World!' as its content
Correct Answer:
A
Chapter: 18
Q259:
In the syntax `CREATE OR REPLACE PROCEDURE procedure_name [(parameter_name [IN | OUT | IN OUT] type [, ...])] {IS | AS} BEGIN < procedure_body > END procedure_name;`, what does `IN` specify?
A. A read-only parameter
B. A parameter that can be both read and written
C. A writable parameter
D. A parameter that returns data to the caller
Correct Answer:
A
Chapter: 18
Q260:
What does an `OUT` parameter do in a PL/SQL procedure?
A. Passes a value to the procedure
B. Returns a value to the calling environment
C. Specifies a read-only value
D. Defines a parameter with no data type
Correct Answer:
B