SQL: set existing column as Primary Key in MySQL

核能气质少年 提交于 2019-12-02 17:49:54

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_table
ADD 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

Ravi Kamesh
alter table table_name
add constraint myprimarykey primary key(column);

reference : http://www.w3schools.com/sql/sql_primarykey.asp

Go to localhost/phpmyadmin and press enter key. Now select database --> table_name --->Structure --->Action ---> Primary -->click on Primary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!