Is there a sqlite query size limit?

Is there any limit to how big the select statement is? for example, suppose I have 100 failed students as a selection, will my code below work?

ArrayList<Long> ids_toupdate = getFailedStudents();// has size 100.
String selection = String.format(Locale.US, STUDENT._ID + " IN (%s)",TextUtils.join(", ", ids_toupdate));
ContentValues cv = new ContentValues();
cv.put(RawContacts.FAILED, 1);
getContentResolver().update(STUDENT.CONTENT_URI,cv, selection, null);
+4
source share
1 answer

Roughly speaking, the default limit is 1,000,000 bytes or 1,000,000 characters, so if your “students” do not have more than 100,000 characters, each of your statements should be in order.

From http://www.sqlite.org/limits.html

Maximum SQL Statement Length

SQL SQLITE_MAX_SQL_LENGTH, 1000000. , SQLITE_MAX_LENGTH 1073741824.

SQL , , , , INSERT. . . SQL :

INSERT INTO tab1 VALUES(?,?,?); 

sqlite3_bind_XXXX() SQL. , SQL-. , .

SQL , sqlite3_limit (db, SQLITE_LIMIT_SQL_LENGTH, ).

+6

Source: https://habr.com/ru/post/1546681/


All Articles