Sql: Set Existing Column As Primary Key In Mysql
I have a database with 3 columns: id, name, somethingelse This table has no index set and i am getting 'No index defined!' in phpmyadmin id is a 7digit alphanumeric value, uniq
Solution 1:
Either run in SQL:
ALTERTABLE tableName
ADDPRIMARY KEY (id) ---or Drugid, whichever you want it to be PKor use the PHPMyAdmin interface (Table Structure)
Solution 2:
ALTERTABLE your_table
ADDPRIMARY KEY (Drugid);
Solution 3:
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
Solution 4:
altertable table_name
addconstraint myprimarykey primary key(column);
reference : http://www.w3schools.com/sql/sql_primarykey.asp
Solution 5:
Go to localhost/phpmyadmin and press enter key. Now select:
database --> table_name --->Structure --->Action ---> Primary -->click on Primary
Post a Comment for "Sql: Set Existing Column As Primary Key In Mysql"