2009-04-30 61 views

回答

7
DELETE FROM 
    MyTable 
WHERE 
    Id = (SELECT MIN(Id) FROM MyTable); 
0
DELETE FROM 
    tablename 
WHERE 
    rowid= (SELECT MIN(rowid) FROM tablename) 
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未編入索引。