sqlite 表中的最大行数?

发布于 2024-12-26 04:14:07 字数 1401 浏览 1 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

苦行僧 2025-01-02 04:14:07

您可以获取有关 SQLite 限制 的标准信息,但这不会是导致问题的原因你的问题是因为限制实际上非常高。 (2 的 64 次方!)

您的问题很可能与您的应用程序插入记录的方式和/或插入的记录的类型有关。

您可以发布一些应用程序的代码以及它如何处理插入吗?我可以在阅读后修改我的答案。

作为补充提示,请确保您已设置:

Cursor myCursor = db.rawQuery("PRAGMA synchronous=OFF", null); 
myCursor.close();

因为这确实可以提高性能较大的批量插入。

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:

Cursor myCursor = db.rawQuery("PRAGMA synchronous=OFF", null); 
myCursor.close();

As this can really improve the performance of your larger bulk inserts.

腻橙味 2025-01-02 04:14:07

表中的最大行数

表中的理论最大行数为 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

李白 2025-01-02 04:14:07

没有这样的限制,请参见下文:

它说:

最大行数在表中

表中的理论最大行数为 264
(18446744073709551616 或约 1.8e+19)。这个限制是无法达到的
因为首先将达到 14 TB 的最大数据库大小。
14 TB 的数据库最多只能容纳大约 1e+13
行,然后仅当没有索引并且每行包含
数据很少。

There are no such limits, see below:

It says:

Maximum Number Of Rows In A Table

The theoretical maximum number of rows in a table is 264
(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.

忆梦 2025-01-02 04:14:07

最大行数为 2^64。

这是限制页面

Maximum number of rows is 2^64.

Here is the limitation page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文