MySQL Forums
Forum List  »  Newbie

Re: webmin: it has no primary key
Posted by: Felix Geerinckx
Date: August 11, 2005 07:37AM

Kimberly Johnson wrote:

> Webmin mysql "view data" shows the data and:
>
> Data in this table cannot be edited because it has no primary key.

To be able to edit (update/delete) a record you need a way to find to it. With a primary key it's easy, e.g.

UPDATE foo SET ... WHERE id = <some_value>

When you don't have a primary (or unique) key, there is no way to locate the record.

The best you can do in that case is

UPDATE foo SET col1 = 'newval1', col2 = 'newval2'
WHERE col1 = 'oldval1' AND col2 = 'oldval2'
LIMIT 1;

but this does not guarantee that you will update the correct record. So I guess that's the reason why webmin doesn't allow it.

There is an easy solution though: add a primary key to your table.

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Written By
Posted
Re: webmin: it has no primary key
August 11, 2005 07:37AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.