CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2022
    Location
    Urbana, Illinios
    Posts
    14

    PRIMARY KEY vs. UNIQUE restrictions in MySQL

    The distinction between a PRIMARY KEY constraint and a UNIQUE constraint, according to the MySQL documentation, is that a PK constraint does not permit NULL values whereas a UQ constraint does. One may generate both PK and UQ for the same column in a MySQL table!

    What use does it serve to add a UNIQUE constraint to a column that already has a PK constraint?
    Why won't MySQL let me add a unique constraint to a column with a PK constraint already?



    Also, I want to ask according to internet definitions the join condition in equi join is equality (=), whereas inner join can contain additional operators such as less than () or larger than (>). A non-equi join is a sort of join in which the join condition does not employ equals. Does this imply that non-equi joins and inner joins are the same?
    Last edited by 2kaud; December 17th, 2022 at 11:27 AM. Reason: Web site reference removed

  2. #2
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: PRIMARY KEY vs. UNIQUE restrictions in MySQL

    In SQL language, NULL simply means "unknown value" or "not yet set value". Because a primary key is intended to (unique) identify a record in a table, a NULL PK has no sense, so is not permitted.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

Tags for this Thread

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

Featured