DBAsupport.com Forums - Powered by vBulletin
Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 31

Thread: Not Null on Primary Key???

  1. #21
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    Originally posted by slimdave
    SQL> create table my_table (my_column number
    2 constraint xpkmy_table primary key deferrable);

    Table created.

    SQL> insert into my_table values(1);

    1 row created.

    SQL> set constraint xpkmy_table deferred;

    Constraint set.

    SQL> insert into my_table values (null);

    1 row created.

    SQL> insert into my_table values (null);

    1 row created.

    SQL> insert into my_table values (null);

    1 row created.

    SQL> insert into my_table values (1);

    1 row created.

    SQL> commit;
    commit
    *
    ERROR at line 1:
    ORA-02091: transaction rolled back
    ORA-01400: cannot insert NULL into ()

    Ta Da!

    SOHK: 2 OCP: 0
    Jeff Hunter

  2. #22
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Perhaps we could award a new certification.

    OCDP = Oracle Certified Documentation Peruser
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  3. #23
    Join Date
    Dec 1999
    Location
    Purgatory
    Posts
    346
    Will you lot stop flirting..........

  4. #24
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    funny

  5. #25
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Originally posted by Horace
    Will you lot stop flirting..........
    Well, if that's what passes for flirting in Nottingham nowadays, it's a pretty sorry business. It were different in my day ...
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  6. #26
    Join Date
    Dec 1999
    Location
    Purgatory
    Posts
    346
    Ah Dave,

    But that was during the war, when all the boys were away........

  7. #27
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    ... and on a Saturday night the world could be yours for the cost of a pair of nylons.
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  8. #28
    Join Date
    Nov 2000
    Location
    Baltimore, MD USA
    Posts
    1,339
    Mayday! Mayday!

    We've drifted WAY off course here and the fuel is spent.

    We're going down! Repeat, we are going down!



    - Chris
    Christopher R. Long
    ChrisRLong@HotMail.Com
    But that's just my opinion. I could be wrong

  9. #29
    Join Date
    Dec 2000
    Posts
    138
    Originally posted by slimdave
    SQL> create table my_table (my_column number
    2 constraint xpkmy_table primary key deferrable);

    Table created.

    SQL> insert into my_table values(1);

    1 row created.

    SQL> set constraint xpkmy_table deferred;

    Constraint set.

    SQL> insert into my_table values (null);

    1 row created.

    SQL> insert into my_table values (null);

    1 row created.

    SQL> insert into my_table values (null);

    1 row created.

    SQL> insert into my_table values (1);

    1 row created.

    SQL> commit;
    commit
    *
    ERROR at line 1:
    ORA-02091: transaction rolled back
    ORA-01400: cannot insert NULL into ()

    Ta Da!



    Calvin: A deferrable PK also enforce that the set of columns are not null.

    SlimDave: Not when it's deferred is doesn't


    It ofcourse enforces the primary key aint it!!! atleast at the end of the transaction - which is because of the "Deferred" until the end of a Tx..
    am I right here..

    Hmmmm..

  10. #30
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    The point that we were discussing was whether it was desirable to have both a primary key and a not null constraint on the same column(s), and the conclusion was that it wasn't.

    The whole thing with the deferrable pk constraint was that there might be a circumstance in which you wanted the uniqueness of the pk to be deferred, but wanted to maintain the not null-ness, in which case it might be proper to place a separate not null constraint on the columns.
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width