nerdexam
Oracle

1Z0-052 · Question #165

You have two tables with referential integrity enforced between them. You need to insert data to the child table first because it is going to be a long transaction and data for the parent table will…

The correct answer is A. Set the constraint to deferred before starting the transaction. Oracle allows deferring constraint checking to the end of a transaction by setting a DEFERRABLE constraint to DEFERRED mode before the transaction begins.

Managing Schema Objects

Question

You have two tables with referential integrity enforced between them. You need to insert data to the child table first because it is going to be a long transaction and data for the parent table will be available in a later stage, which can be inserted as part of the same transaction. View the Exhibit to examine the commands used to create tables. Which action would you take to delay the referential integrity checking until the end of the transaction?

Exhibit

1Z0-052 question #165 exhibit

Options

  • ASet the constraint to deferred before starting the transaction
  • BAlter the constraint to NOVALIDATE state before starting the transaction
  • CEnable the resumable mode for the session before starting the transaction
  • DSet the COMMIT_WAIT parameter to FORCE_WAIT for the session before starting the transaction

How the community answered

(55 responses)
  • A
    78% (43)
  • B
    13% (7)
  • C
    4% (2)
  • D
    5% (3)

Why each option

Oracle allows deferring constraint checking to the end of a transaction by setting a DEFERRABLE constraint to DEFERRED mode before the transaction begins.

ASet the constraint to deferred before starting the transactionCorrect

The SET CONSTRAINT ... DEFERRED command instructs Oracle to postpone referential integrity checking until COMMIT, allowing child rows to be inserted before their parent rows within the same transaction, provided the constraint was originally created with the DEFERRABLE clause.

BAlter the constraint to NOVALIDATE state before starting the transaction

The NOVALIDATE state exempts existing rows from validation but still enforces the constraint immediately for new DML operations - it does not defer checking to end of transaction.

CEnable the resumable mode for the session before starting the transaction

Resumable mode suspends a statement when it encounters a resource shortage such as out-of-space conditions, and has no effect on constraint enforcement timing.

DSet the COMMIT_WAIT parameter to FORCE_WAIT for the session before starting the transaction

The COMMIT_WAIT parameter controls whether a commit waits for redo data to be flushed to disk before returning to the caller, and is completely unrelated to constraint checking behavior.

Concept tested: Oracle deferrable constraints and SET CONSTRAINT DEFERRED

Source: https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/SET-CONSTRAINT.html

Topics

#deferred constraints#referential integrity#constraint deferral#transaction integrity

Community Discussion

No community discussion yet for this question.

Full 1Z0-052 Practice