regarding primary key

  • hi friends,

    i have a doubt while creating database. can we have same column name as primary key in two different tables?

    plz help me if u can.

    Thanks in advance,

    cheers,

    ram.

  • Yes you can.

    .

  • the logic behind it is that column1 in tablea as a PK and column1 in tableb as a PK are different because the tables are different.

    the 'fullname', if you will, of each primary key is the name of the table plus the column name. No different than having the same table name in a different database on the same server.

    Just helping with the thought process

  • the 'fullname', if you will, of each primary key is the name of the table plus the column name.

    The name of the primary key is whatever you specify it to be and that name must be unique in the database. Default if not specified is PK__<Table Name> followed by a hash.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply