Add A Primary Key To An Existing Database Table With SQL

August - 2021

Do this to add a primary key to an existing database table:

ALTER TABLE table_name ADD PRIMARY KEY (column_name)

You can make the primary key with multiple columns as well

ALTER TABLE table_name ADD PRIMARY KEY (column_name_1, column_name_2)