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!

primary key- alter table

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

  1. monkey

    monkey Long Term Member

    Messages:
    156
    Likes Received:
    0
    Trophy Points:
    230
    Hello!
    Here it is writen:
    http://www.w3schools.com/sql/sql_primarykey.asp

    But, when we were declaring primary key using alter table, we wrote:

    alter table x
    add(constraint pk_x primary key (IDx));

    a little bit different. Are there some important comments about the difference?
    many thanks!!!
     
  2. rajenb

    rajenb Forum Expert

    Messages:
    361
    Likes Received:
    114
    Trophy Points:
    655
    Location:
    Mauritius
    Re: primary key- alter table

    You can use both ways to create Primary Key: either you provide a name (like pk_x in your example) or you don't provide any and Oracle creates the Primary key with a default name of SYS_xxxxxxxxxx where xxxxxxxxxx is a system generated unique identifier.
     
  3. monkey

    monkey Long Term Member

    Messages:
    156
    Likes Received:
    0
    Trophy Points:
    230
    Re: primary key- alter table

    Hello!
    It means: in:

    alter table x
    add(constraint pk_x primary key (IDx));==ADD PRIMARY KEY (IDx);
     
  4. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,347
    Likes Received:
    348
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    Re: primary key- alter table

    And do you understand what a primary key is and what it does?
     
  5. monkey

    monkey Long Term Member

    Messages:
    156
    Likes Received:
    0
    Trophy Points:
    230
    Re: primary key- alter table

    On the beginners level: yes. If there is sth more complicated with that to appear later, not know at moment.
     
  6. jagadekara

    jagadekara Forum Guru

    Messages:
    1,126
    Likes Received:
    145
    Trophy Points:
    1,805
    Location:
    Pulivendula