如何从具有最低rowid的表中删除行? 谢谢。
答案 0 :(得分:8)
DELETE FROM
MyTable
WHERE
Id = (SELECT MIN(Id) FROM MyTable);
答案 1 :(得分:4)
在大多数情况下,rowid是一个索引列。如果是这种情况,多更快的解决方案是:
DELETE FROM
tablename
WHERE
rowid= (SELECT rowid FROM tablename order by rowid limit 1)
如果没有索引rowid,那么:
DELETE FROM
tablename
WHERE
rowid= (SELECT MIN(rowid) FROM tablename)
我仍然会测试第一个,因为它通常会更快,即使rowid没有编入索引。
答案 2 :(得分:0)
DELETE FROM
tablename
WHERE
rowid= (SELECT MIN(rowid) FROM tablename)