Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite error: too many terms in compound SELECT

Tags:

select

sqlite

ios

When I insert too many data into sqlite database file, an error "too many terms in compound SELECT" occurs. I use "insert into ... select ... union select ... union ...". I know it's too many select statements, but my question is: What's the maximum number of terms in a compound SELECT statement?

like image 756
Smeegol Avatar asked Mar 02 '12 04:03

Smeegol


1 Answers

A compound SELECT statement is two or more SELECT statements connected by operators UNION, UNION ALL, EXCEPT, or INTERSECT. We call each individual SELECT statement within a compound SELECT a "term".

The code generator in SQLite processes compound SELECT statements using a recursive algorithm. In order to limit the size of the stack, we therefore limit the number of terms in a compound SELECT. The maximum number of terms is SQLITE_MAX_COMPOUND_SELECT which defaults to 500. We think this is a generous allotment since in practice we almost never see the number of terms in a compound select exceed single digits.

The maximum number of compound SELECT terms can be lowered at run-time using the sqlite3_limit(db,SQLITE_LIMIT_COMPOUND_SELECT,size) interface.

for more details please check this... http://www.sqlite.org/limits.html

like image 113
shofee Avatar answered Sep 18 '22 14:09

shofee