Results 1 to 3 of 3

Thread: Constraints

  1. #1
    Contributing Member
    Join Date
    Mar 2008
    Answers
    66

    Constraints

    What is the difference between deferrable and not deferrable constraints?


  2. #2
    Expert Member
    Join Date
    Sep 2007
    Answers
    697

    Re: Constraints

    >>What is the difference between deferrable and not deferrable constraints?

    By default constraints are not deferrable. They will notify immedietly on violation of constraint.

    By setting a constraint as deferrable oracle checks voilation only at commit point i.e. at the end of the transaction.

    Code:
    SQL> CREATE TABLE TEST_CONS ( NUM NUMBER(10) CONSTRAINT NUM_PK PRIMARY KEY DEFERRABLE);
    
    Table created.
    
    SQL> SET  CONSTRAINT NUM_PK DEFERRED;
    
    Constraint set.
    
    SQL> INSERT INTO TEST_CONS VALUES(1);
    
    1 row created.
    
    SQL> INSERT INTO TEST_CONS VALUES(1);
    
    1 row created.
    
    SQL> COMMIT;
    COMMIT
    *
    ERROR at line 1:
    ORA-02091: transaction rolled back
    ORA-00001: unique constraint (CMSJAN.NUM_PK) violated



  3. #3
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: Constraints

    Deferrable constraints allows to go for transactions but not commit them .It checks for data integrity only at the time of commit not during normal transactions.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact