1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Possible consequences, if one doesn't declare the primary key of the table?

Discussion in 'SQL PL/SQL' started by monkey, Jun 7, 2014.

  1. monkey

    monkey Long Term Member

    Messages:
    156
    Likes Received:
    0
    Trophy Points:
    230
    Hello!
    Please, can someone describe me easiest and most frequent case, what dammage can happen if we do not declare the primary key creating a table?

    Is the expression "declare primary key" apporpriate?
    Many thanks!!!
     
  2. rajenb

    rajenb Forum Expert

    Messages:
    361
    Likes Received:
    114
    Trophy Points:
    655
    Location:
    Mauritius
    As the term "Primary Key" implies, it helps to uniquely identify a row in a table.
    It doesn't cause any "damage" if we don't define it but your table may end up with duplicates if it is not supposed to have them.

    As for the creation syntax, please refer to link: http://www.techonthenet.com/oracle/primary_keys.php
     
  3. monkey

    monkey Long Term Member

    Messages:
    156
    Likes Received:
    0
    Trophy Points:
    230
    Hello!
    What did U mean when saying "with duplicates"?
    many thanks!!!
     
  4. rajenb

    rajenb Forum Expert

    Messages:
    361
    Likes Received:
    114
    Trophy Points:
    655
    Location:
    Mauritius
    For example, like in your previous post with STUDENTS table, if you don't have a Primary key on student_id, you may end up with 2 students having same student_id with same or different name .. then when you search your student with Id then don't know which is which !
     
    monkey likes this.