Pavan Ramamurthy
Can a table have more than one Primary Key ?

Commonly asked question in an interview ?

By Pavan Ramamurthy in SQL on May 05 2023
  • Tanima K
    May, 2023 6

    No, but can have more than one unique keys constraints.

    • 1
  • Kousalya Palani
    Jul, 2023 13

    No. But you can do it by using composite primary key, which consists of multiple columns, to uniquely identify each row in a table

    • 0
  • Abhijit Das
    Jun, 2023 21

    no

    • 0
  • Vijay K
    Jun, 2023 20

    No,You cannot have two primary keys in one table.But primary can contain multiple fields.When you create table,when you mention primary key you can more then one column which you want.
    like,
    CREATE TABLE table_name ( col1 Datatype , col2 Datatype,col3 Datatype, col4 Datatype, PRIMARY KEY (col1,col2,col3) )

    • 0
  • Kavya Chowdary
    May, 2023 26

    No. Because Primary key is an identity to the row. There cannot be two identities against a row.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS