How do you enable LIMIT for DELETE in SQLite? How do you enable LIMIT for DELETE in SQLite? sqlite sqlite

How do you enable LIMIT for DELETE in SQLite?


You can use limit with select and you can combine select and delete like:

DELETE FROM FooWHERE someColumn in(  SELECT someColumn FROM FOO WHERE SomeCondition LIMIT 200)


DELETE FROM table WHERE rowid = (SELECT rowid FROM table WHERE condition LIMIT 1 )


You cannot enable these options from within PHP, you need to compile SQLite yourself in order to enable these options. Importantly, you need to download the full version, not the amalgamation source release from SQLite download page.

If you're on Unix, get the sqlite-3.6.20.tar.gz tarball and download it. Then:

tar xzf sqlite-3.6.20.tar.gzcd sqlite-3.6.20export CFLAGS='-DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1'./configuremake

Then you'll have the sqlite3 command-line utility and the library files in the .libs subdirectory.