73

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, unique to each row.
I want to set Drugid to be the primarykey/index (i dont know the difference if there is one)
Please explain in detail as i am new to this.
Thank you.

Ortiga
  • 8,455
  • 5
  • 42
  • 71
krasatos
  • 1,177
  • 3
  • 13
  • 26

5 Answers5

123

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)

ypercubeᵀᴹ
  • 113,259
  • 19
  • 174
  • 235
6
ALTER TABLE your_table
ADD PRIMARY KEY (Drugid);
juergen d
  • 201,996
  • 37
  • 293
  • 362
4

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

Ortiga
  • 8,455
  • 5
  • 42
  • 71
3
alter table table_name
add constraint myprimarykey primary key(column);

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

Michał Powaga
  • 22,561
  • 8
  • 51
  • 62
0

Go to localhost/phpmyadmin and press enter key. Now select:

database --> table_name --->Structure --->Action  ---> Primary -->click on Primary 
frianH
  • 7,295
  • 6
  • 20
  • 45