SQL: set existing column as Primary Key in MySQL SQL: set existing column as Primary Key in MySQL mysql mysql

SQL: set existing column as Primary Key in MySQL


Either run in SQL:

ALTER TABLE tableName  ADD PRIMARY KEY (id)           ---or Drugid, whichever you want it to be PK

or use the PHPMyAdmin interface (Table Structure)


ALTER TABLE your_tableADD PRIMARY KEY (Drugid);


If you want to do it with phpmyadmin interface:

Select the table -> Go to structure tab -> On the row corresponding to the column you want, click on the icon with a key