sqlite 表中的最大行数?
sql lite 表的行数是否有限制? 当该表超过 6000 行时,我的应用程序给出错误“没有这样的表 x...”。 在 6000 行以下,不要给出任何错误。
谢谢。
这是查询。
db = (new DatabaseHelper(this)).getWritableDatabase();
cursor = db.rawQuery("SELECT continentes._id, continentes.ContinenteID, continentes.Continente"
+ " FROM continentes"
+ " WHERE continentes.Continente LIKE ?"
+ " GROUP BY continentes.ContinenteID, continentes.Continente ORDER BY continentes.Continente",
new String[]{"%" + searchText.getText().toString() + "%"});
这是我创建表的地方
@Override
public void onCreate(SQLiteDatabase db) {
String s;
try {
Toast.makeText(context, "Creating Database", 2000).show();
InputStream in = context.getResources().openRawResource(R.raw.continentes);
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.parse(in, null);
NodeList statements = doc.getElementsByTagName("statement");
for (int i=0; i<statements.getLength(); i++) {
s = statements.item(i).getChildNodes().item(0).getNodeValue();
db.execSQL(s);
}
} catch (Throwable t) {
Toast.makeText(context, t.toString(), 50000).show();
已解决!我只是找出为什么我遇到这个问题。因为我与数据一起使用来创建和填充 sql 数据库的文件不能超过 1.2mb。所以,我把它们分开了,没有更多的问题。感谢大家。
Is there some limit of rows for a sql lite table ?
My app is giving a error " no such table x..." when that table have more than 6000 rows.
Below the 6000 rows, dont give any error.
Thank you.
This is the query.
db = (new DatabaseHelper(this)).getWritableDatabase();
cursor = db.rawQuery("SELECT continentes._id, continentes.ContinenteID, continentes.Continente"
+ " FROM continentes"
+ " WHERE continentes.Continente LIKE ?"
+ " GROUP BY continentes.ContinenteID, continentes.Continente ORDER BY continentes.Continente",
new String[]{"%" + searchText.getText().toString() + "%"});
This is where i create the table
@Override
public void onCreate(SQLiteDatabase db) {
String s;
try {
Toast.makeText(context, "Creating Database", 2000).show();
InputStream in = context.getResources().openRawResource(R.raw.continentes);
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.parse(in, null);
NodeList statements = doc.getElementsByTagName("statement");
for (int i=0; i<statements.getLength(); i++) {
s = statements.item(i).getChildNodes().item(0).getNodeValue();
db.execSQL(s);
}
} catch (Throwable t) {
Toast.makeText(context, t.toString(), 50000).show();
SOLVED !!! I just find out why i got this problem. Because the files that i use with Data to create and populate the sql database, can´t have more than 1.2mb. So, i split them, and dont have more problems. Thanks to all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以获取有关 SQLite 限制 的标准信息,但这不会是导致问题的原因你的问题是因为限制实际上非常高。 (2 的 64 次方!)
您的问题很可能与您的应用程序插入记录的方式和/或插入的记录的类型有关。
您可以发布一些应用程序的代码以及它如何处理插入吗?我可以在阅读后修改我的答案。
作为补充提示,请确保您已设置:
因为这确实可以提高性能较大的批量插入。
You can get the standard information on the limits of SQLite but that isn't going to be what's causing your issue as the limit is actually very high. (2 to the power of 64!)
More than likely your issue has to do with how your application is inserting the records and/or the types of records being inserted.
Can you post some code for the application and how it's handling the insert? I can revise my answer after reading through it.
As an added tip, make sure you've set:
As this can really improve the performance of your larger bulk inserts.
表中的最大行数
表中的理论最大行数为 2^64(18446744073709551616 或大约 1.8e+19)。由于首先会达到 14 TB 的最大数据库大小,因此无法达到此限制。 14 TB 的数据库只能容纳不超过大约 1e+13 行,而且前提是没有索引并且每行包含的数据非常少。
从这里开始: http://www.sqlite.org/limits.html
Maximum Number Of Rows In A Table
The theoretical maximum number of rows in a table is 2^64 (18446744073709551616 or about 1.8e+19). This limit is unreachable since the maximum database size of 14 terabytes will be reached first. A 14 terabytes database can hold no more than approximately 1e+13 rows, and then only if there are no indices and if each row contains very little data.
from here: http://www.sqlite.org/limits.html
没有这样的限制,请参见下文:
SQLite 中的限制
限制
它说:
最大行数在表中
There are no such limits, see below:
Limits In SQLite
Limits
It says:
Maximum Number Of Rows In A Table
最大行数为 2^64。
这是限制页面。
Maximum number of rows is 2^64.
Here is the limitation page.