Menu

#1392 Delete from tables with no primary key

Fixed
nobody
None
Default
Enhancement
2010-03-14
2009-10-04
Anonymous
No

Originally created by: dominik....@googlemail.com

What is the problem that needs to be solved (required)?

I would like to delete some rows from a table that does not contain a
PRIMARY KEY. This used to be possible in HeidiSQL 3.

What is the idea in abstract terms (optional)?

In phpMyAdmin the feature works as follows: If there is no primary key,
the DELETE query simply includes all data fields, e.g.,

DELETE FROM a WHERE f1="test" AND f2=3 AND f3=21 LIMIT 1.

I am not sure, if this was the solution in the old version. However, by
using the LIMIT, even identical entries are no problem: There by
definition is no inherent order in database entried.

Greetings
Dominik

Related

Tickets: #1495
Tickets: #1565
Tickets: #1578

Discussion

  • Anonymous

    Anonymous - 2009-10-04

    Originally posted by: a...@anse.de

    > However, by using the LIMIT, even identical entries are no problem

    Really? :) Indeed that is dangerous - you'll never know which row you're deleting,
    and which comes first. For security reasons that was disabled in the recent releases.
    On the other side this fact should teach users to create reasonable primary or unique
    keys for their tables.

    Status: WontFix

     
  • Anonymous

    Anonymous - 2009-10-04

    Originally posted by: dominik....@googlemail.com

    Yes, I guessed that this feature was disabled for security reasons. Maybe a warning
    before deleting would also do.

    However, by definition two entries with the same data in a database are absolutely
    equal (there is no natural order in the database). Therefore it is irrelevant, which
    one of the two is deleted.

     
  • Anonymous

    Anonymous - 2009-10-04

    Originally posted by: a...@anse.de

    Oh ok I see, yes that would indeed make sense then.

    Status: Accepted

     
  • Anonymous

    Anonymous - 2009-10-04

    Originally posted by: dominik....@googlemail.com

    Thanks a lot for accepting the issue - this will save me (and hopefully many other
    users) some trouble :)

     
  • Anonymous

    Anonymous - 2010-03-13

    Originally posted by: a...@anse.de

    Just started working on this issue, so it will go into the 5.0 GA release.

    There will only be one situation left where editing is blocked - when you have
    deselected columns from being displayed. Hmm, I could just hide these columns, but
    select them, so they are available internally.

     
  • Anonymous

    Anonymous - 2010-03-14

    Originally posted by: a...@anse.de

    Done. Was easier to implement than I thought. Feel free to mess up your key-less
    tables now :)