Oracle Database Quiz Questions

Course Name:Oracle
Chapter Name:Chapter 8 - RDBMS Concepts
Lesson Content Link:Foreign Key
Current Quiz Count:30
Progress
0%
Q1
True / False

In Oracle, a foreign key is a column or a set of columns that establishes a link between data in two tables.

Q2
True / False

In Oracle, a foreign key column can contain NULL values.

Q3
True / False

In Oracle, a foreign key constraint automatically creates an index on the foreign key column(s).

Q4
True / False

In Oracle, a foreign key must reference a primary key in another table.

Q5
True / False

In Oracle, you can define a foreign key constraint at both the column level and the table level.

Q6
True / False

In Oracle, a table can have multiple foreign keys.

Q7
True / False

In Oracle, cascading delete is an option where deleting a row in the parent table automatically deletes the related rows in the child table.

Q8
True / False

In Oracle, you can disable a foreign key constraint temporarily without dropping it.

Q9
True / False

In Oracle, adding a foreign key constraint to a column with existing data that violates the constraint will result in an error.

Q10
True / False

The Oracle Certified Professional (OCP) exam includes knowledge on creating, modifying, and managing foreign key constraints, as well as understanding their impact on database integrity and performance.

Q11
Single Choice

What is the primary purpose of a foreign key in an Oracle database?

Q12
Single Choice

In Oracle SQL, which constraint must be enforced on a foreign key column?

Q13
Single Choice

Which of the following SQL commands creates a foreign key on the department_id column of the employees table that references the departments table?

Q14
Single Choice

Consider the following Oracle SQL query:What does this query do?

SQL Code
CREATE TABLE orders (
 order_id NUMBER PRIMARY KEY,
 customer_id NUMBER,
 CONSTRAINT fk_customer FOREIGN KEY (customer_id) REFERENCES customers(customer_id)
);
Q15
Single Choice

Which Oracle SQL query will correctly delete the fk_customer foreign key constraint from the orders table?

Q16
Single Choice

Given the Oracle SQL query:What does the ON DELETE CASCADE clause do?

SQL Code
ALTER TABLE employees ADD CONSTRAINT fk_dept FOREIGN KEY (department_id) REFERENCES departments(department_id) ON DELETE CASCADE;
Q17
Single Choice

What will happen if you try to insert a value in the customer_id column of the orders table that does not exist in the customer_id column of the customers table (given that customer_id is a foreign key)?

Q18
Single Choice

Consider this Oracle SQL query:What does the ON DELETE SET NULL clause do?

SQL Code
CREATE TABLE employees (
 employee_id NUMBER PRIMARY KEY,
 department_id NUMBER,
 CONSTRAINT fk_department FOREIGN KEY (department_id) REFERENCES departments(department_id) ON DELETE SET NULL
);
Q19
Single Choice

Which of the following is true about foreign keys and referential integrity in Oracle?

Q20
Single Choice

Consider the following Oracle SQL scenario:What does this SQL code demonstrate?

SQL Code
CREATE TABLE orders (
 order_id NUMBER PRIMARY KEY,
 product_id NUMBER,
 customer_id NUMBER,
 CONSTRAINT fk_product FOREIGN KEY (product_id) REFERENCES products(product_id) ON DELETE CASCADE,
 CONSTRAINT fk_customer FOREIGN KEY (customer_id) REFERENCES customers(customer_id) ON DELETE SET NULL
);
Q21
Multiple Choice

Identify the correct SQL statements that will successfully create a foreign key relationship in Oracle.

SQL Code
CREATE TABLE departments (
 department_id NUMBER PRIMARY KEY,
 department_name VARCHAR2(100)
);
CREATE TABLE employees (
 employee_id NUMBER PRIMARY KEY,
 department_id NUMBER,
 FOREIGN KEY (department_id) REFERENCES departments(department_id)
);
Q22
Multiple Choice

Select the SQL statements that demonstrate how to handle foreign key constraints when deleting rows.

Q23
Multiple Choice

Determine the SQL statements that demonstrate the use of foreign key constraints in a many-to-one relationship.

Q24
Multiple Choice

Identify the SQL statements that enforce referential integrity using foreign key constraints with cascading updates.

Q25
Multiple Choice

Choose the SQL statements that correctly demonstrate the use of foreign key constraints in a self-referencing table.

Q26
Multiple Choice

Which SQL statements demonstrate how to modify an existing foreign key constraint to add cascading delete behavior?

Q27
Multiple Choice

Determine the SQL statements that ensure referential integrity when inserting data into a child table with a foreign key constraint.

Q28
Multiple Choice

Identify the SQL statements that demonstrate the use of composite foreign keys in Oracle.

Q29
Multiple Choice

Select the SQL statements that correctly enforce foreign key constraints in a one-to-one relationship.

Q30
Multiple Choice

Choose the SQL statements that demonstrate how to troubleshoot foreign key constraint violations in Oracle.