Oracle Database MCQ Banner

Oracle Database Multiple Choice Questions (MCQs) and Answers

Master Oracle Database with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of Oracle Database concepts. Begin your placement preparation journey now!

Q31

Q31 An SQL query fails with "ORA-01722: invalid number." What is the probable cause?

A

A string value compared to a number

B

Null value in the column

C

Column does not exist

D

Table does not exist

Q32

Q32 A query returns a "missing keyword" error. What could be the issue?

A

Missing a semicolon

B

Incorrect function syntax

C

Using a reserved keyword

D

All of the above

Q33

Q33 What is the purpose of PL/SQL in Oracle?

A

To execute SQL commands dynamically

B

To manage database users

C

To add procedural capabilities to SQL

D

To store data in tables

Q34

Q34 Which block structure is mandatory in a PL/SQL program?

A

DECLARE and BEGIN

B

BEGIN and END

C

DECLARE, BEGIN, and EXCEPTION

D

BEGIN, EXCEPTION, and END

Q35

Q35 What is a stored procedure in Oracle?

A

A precompiled collection of SQL and PL/SQL

B

A type of database table

C

A type of data index

D

A database view

Q36

Q36 Which PL/SQL keyword is used to handle exceptions?

A

CATCH

B

HANDLE

C

RAISE

D

EXCEPTION

Q37

Q37 What is the difference between a function and a procedure in PL/SQL?

A

A function must return a value; a procedure cannot

B

A procedure must return a value; a function cannot

C

Functions and procedures are the same

D

A function cannot have parameters

Q38

Q38 Which cursor type is used when the SELECT statement retrieves multiple rows?

A

Static

B

Dynamic

C

Explicit

D

Implicit

Q39

Q39 Write a PL/SQL block to assign a value to a variable and print it.

A

BEGIN var_name := 10; PRINT var_name; END;

B

DECLARE var_name NUMBER := 10; BEGIN DBMS_OUTPUT.PUT_LINE(var_name); END;

C

VAR var_name := 10; PRINT var_name;

D

DECLARE BEGIN PRINT var_name := 10; END;

Q40

Q40 Write a PL/SQL block to calculate the sum of two numbers.

A

BEGIN a := 10; b := 20; c := a + b; PRINT c; END;

B

DECLARE a NUMBER := 10; b NUMBER := 20; c NUMBER; BEGIN c := a + b; DBMS_OUTPUT.PUT_LINE(c); END;

C

DECLARE BEGIN a := 10; b := 20; c := a + b; PRINT c; END;

D

VAR a := 10; b := 20; c := a + b; PRINT c;

Q41

Q41 Write a PL/SQL block to iterate through numbers 1 to 5 and print each.

A

BEGIN FOR i IN 1..5 LOOP DBMS_OUTPUT.PUT_LINE(i); END LOOP; END;

B

DECLARE BEGIN FOR i IN 1..5 LOOP DBMS_OUTPUT.PUT_LINE(i); END LOOP; END;

C

DECLARE i NUMBER; BEGIN FOR i IN 1..5 LOOP DBMS_OUTPUT.PUT_LINE(i); END LOOP; END;

D

BEGIN LOOP i FROM 1 TO 5 PRINT i; END LOOP; END;

Q42

Q42 A PL/SQL block fails with the error "ORA-06502: numeric or value error." What is the likely cause?

A

Invalid column name

B

Datatype mismatch

C

Missing keyword

D

Incorrect table name

Q43

Q43 A PL/SQL block returns "ORA-01403: no data found." What should be done to handle this?

A

Add a WHEN NO_DATA_FOUND exception

B

Add a NULL value check

C

Use an IF statement

D

Use a CONTINUE statement

Q44

Q44 A PL/SQL procedure fails to execute due to "ORA-00904: invalid identifier." What could be the issue?

A

Variable not declared

B

Invalid table name

C

Incorrect datatype

D

None of the above

Q45

Q45 What is the primary purpose of a table in Oracle Database?

A

To store data in rows and columns

B

To define database schema

C

To optimize queries

D

To store indexes

Q46

Q46 What is the role of a view in Oracle Database?

A

To create backups

B

To restrict access to specific data

C

To optimize indexes

D

To store large amounts of data

Q47

Q47 Which type of index automatically creates when a primary key is defined?

A

Bitmap Index

B

Unique Index

C

Composite Index

D

B-Tree Index

Q48

Q48 How do materialized views differ from standard views in Oracle Database?

A

They are virtual tables

B

They store precomputed results

C

They only support SELECT queries

D

They are created automatically

Q49

Q49 Which command is used to drop a table in Oracle Database?

A

DELETE TABLE table_name;

B

DROP TABLE table_name;

C

REMOVE table_name;

D

TRUNCATE TABLE table_name;

Q50

Q50 What is the difference between a clustered and non-clustered index?

A

Clustered indexes sort data physically; non-clustered do not

B

Non-clustered indexes are faster

C

Clustered indexes do not sort data

D

Clustered indexes only work on primary keys

Q51

Q51 Write a query to create a table with columns id (NUMBER) and name (VARCHAR2).

A

CREATE TABLE test_table (id NUMBER, name VARCHAR2(50));

B

CREATE TABLE test_table (id INTEGER, name STRING);

C

CREATE test_table id NUMBER, name VARCHAR;

D

DEFINE TABLE test_table (id NUM, name CHAR);

Q52

Q52 Write a query to create an index on the "employee_id" column of the "employees" table.

A

CREATE INDEX emp_idx ON employees(employee_id);

B

CREATE TABLE emp_idx ON employees(employee_id);

C

CREATE INDEX employee_id ON employees;

D

INDEX emp_idx ON employees(employee_id);

Q53

Q53 Write a query to create a materialized view "mv_sales" to store aggregated sales data.

A

CREATE MATERIALIZED VIEW mv_sales AS SELECT SUM(sales) FROM transactions;

B

CREATE VIEW mv_sales AS SELECT SUM(sales) FROM transactions;

C

CREATE TABLE mv_sales AS SELECT SUM(sales) FROM transactions;

D

CREATE AGGREGATE VIEW mv_sales AS SELECT SUM(sales) FROM transactions;

Q54

Q54 A query fails with "ORA-00942: table or view does not exist." What is the probable cause?

A

Table name is misspelled

B

User lacks access privileges

C

Table does not exist

D

Insufficient privileges

Q55

Q55 An index is not being used in a query execution plan. What might be the cause?

A

The index is invalid

B

The index is fragmented

C

The query does not reference indexed columns

D

Query performance degraded

Q56

Q56 A materialized view fails to refresh with "ORA-12012." What could be the issue?

A

Incorrect query definition

B

Missing privileges

C

Lack of space

D

Query not optimized

Q57

Q57 What is a transaction in Oracle Database?

A

A unit of work that can be committed or rolled back

B

A type of SQL query

C

A data storage mechanism

D

A database backup process

Q58

Q58 Which statement begins a transaction in Oracle Database?

A

BEGIN TRANSACTION

B

START TRANSACTION

C

Implicitly starts with first DML statement

D

CREATE TRANSACTION

Q59

Q59 What is the purpose of the COMMIT statement in a transaction?

A

Save changes permanently

B

Undo all changes

C

Perform a backup

D

Lock the table

Q60

Q60 What happens when a ROLLBACK statement is executed?

A

Locks the database

B

Reverts changes made during the current transaction

C

Deletes all data

D

Clears all indexes

ad verticalad vertical
ad