1Z0-060 · Question #158
Which two statements are true regarding constraints?
The correct answer is B. A column with the unique constraint can contain null values. D. A constraint can be disabled even if the constraint column contains data. This question tests knowledge of Oracle SQL constraint behavior, specifically NULL handling with UNIQUE constraints and the ability to disable constraints on columns that already contain data.
Question
Which two statements are true regarding constraints?
Options
- AA foreign key cannot contain null values.
- BA column with the unique constraint can contain null values.
- CA constraint is enforced only for the insert operation on a table.
- DA constraint can be disabled even if the constraint column contains data.
- EAll constraints can be defined at the column level as well as the table level.
How the community answered
(39 responses)- A5% (2)
- B90% (35)
- C3% (1)
- E3% (1)
Why each option
This question tests knowledge of Oracle SQL constraint behavior, specifically NULL handling with UNIQUE constraints and the ability to disable constraints on columns that already contain data.
Foreign key columns can contain NULL values, which simply indicate the absence of a relationship to the parent table - only non-null foreign key values must match an existing primary key in the referenced table.
The UNIQUE constraint prevents duplicate non-null values but permits multiple NULL values because NULL is not considered equal to any value, including another NULL, under standard SQL semantics. Oracle enforces this behavior consistently, so a UNIQUE column may have many rows with NULL without violating the constraint.
Constraints are enforced for all DML operations - INSERT, UPDATE, and DELETE - not only for INSERT, since an UPDATE could introduce a duplicate or a DELETE could orphan child rows.
Oracle's ALTER TABLE ... DISABLE CONSTRAINT command suspends constraint enforcement without requiring the column data to be removed or modified, allowing constraints to be disabled regardless of existing data.
The NOT NULL constraint can only be defined at the column level and cannot be specified as a table-level constraint, so not all constraint types support both definition styles.
Concept tested: Oracle SQL constraint behavior and NULL semantics
Source: https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/constraint.html
Topics
Community Discussion
No community discussion yet for this question.