Chintan Gor
Chintan Gor

Reputation: 1072

what is use of 'KEY' in mysql , it is not allowing me edit record in phpmyadmin

Here is my database mapping table definition, you can try this, when I create this table and add some records in to it, it is not let me edit or delete the records by phpmyadmin although by query it should be possible,

CREATE TABLE IF NOT EXISTS `map2` (
  `map_table_a` varchar(25) DEFAULT NULL,
  `map_id_a` int(10) DEFAULT NULL,
  `map_table_b` varchar(25) DEFAULT NULL,
  `map_id_b` int(10) DEFAULT NULL,
 KEY `map_table_b` (`map_table_b`,`map_id_b`),
 KEY `map_table_a` (`map_table_a`,`map_id_a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

I don't know reason behind this behavior

Upvotes: 0

Views: 99

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324790

Depending on your phpMyAdmin version, you should see this error message:

This table does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available.

While you do have KEY columns, you have no PRIMARY or UNIQUE columns defined. This is why phpMyAdmin cannot edit your data - it has no way to be sure it is editing the correct row.

Suggested solution: Add the following into your table definition, preferably as the first column:

`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY

Upvotes: 3

Related Questions