I'd like to perform the following:
DELETE FROM images WHERE image_address NOT IN (<a long list>)
How long can this list be? I'm guessing I might have to think of another way.
Updated answer (2025): If you are using parameters (?
), the maximum number is 999 for SQLite versions prior to 3.32.0 (2020-05-22) or 32766 for SQLite versions after 3.32.0.
Original answer:
If you are using parameters (?
), the maximum number is 999 by default.
If you are creating the SQL statement dynamically by inserting the values directly (which is a bad thing to do for strings), there is no upper limit on the lenght of such a list. However, there is a limit on the length of the entire SQL statement, which is one million bytes by default.
If you cannot guarantee that your query does not exceed these limits, you must use a temporary table (see LS_dev's answer).