Home / Software / Tips and Tricks / How to Add or remove Primary key to/ from an existing table?

How to Add or remove Primary key to/ from an existing table?

Updated:  07/22/2010 10:07 AM
Author:  Shiju Mathews

Status:    Resolved.


  • The PRIMARY KEY constraint uniquely identifies each record in a database table.
  • Primary keys must contain unique values.
  • A primary key column cannot contain NULL values.
  • Each table can have only ONE primary key.

    Inorder to add a primary key to a table the we need to select a column that has unique values with no 'null' values in the table.

    To add a primary to a table run the following script.



    OR



    To drop a primary to a table run the following script.
  •