SQLITE3 增加最大列数 [英] SQLITE3 increase Max Columns

查看:53
本文介绍了SQLITE3 增加最大列数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑使用 SQLlite3,所以我开始了一些性能测试.

I am thinking about using SQLlite3 so I started some performance tests.

因为我有一个包含许多列的表,所以我想从 SQLite3 增加 MAX Column Limit.当我在 SQLite 网站上阅读时,限制设置为 2000 列,现在我想增加它.

Because I've got an table with many Columns I want to increase the MAX Column Limit from SQLite3. As I read on the SQLite website the limit was set to 2000 columns and now I want to increase it.

我想使用 sqlite3_limit() 但是,因为我使用 SQLAPI,所以我不能使用这个函数.

I wanted to use sqlite3_limit() but, because I use SQLAPI, I cannot use this function.

我在一些网站上读到我需要更改 SQLite内部"的某些内容,然后必须重新编译它,但我还没有真正理解这部分,所以我想问:

I've read on some website I need to change something "inside" SQLite and then have to recompile it but I haven't really understood this part and so I wanted to ask:

还有其他方法可以增加最大列数吗?

Is there was another way to increase Max columns?

我的程序在 Win10 上用 C++ 运行

My programm is running on Win10 in c++

推荐答案

没有其他办法,只能在编译时设置你想要的列数.

There is no other way but by setting the number of columns you want at compile time.

幸运的是,这并不难.

  1. 此处下载合并源代码.它被命名为 sqlite-amalgamation-*.zip
  2. 解压缩并更改解压缩文件夹中的目录.您将看到 sqlite3.csqlite3.h 以及其他文件.
  3. 发出此语句以创建目标文件并设置所需的列数:gcc -I.-O3 -DSQLITE_MAX_COLUMN=5000 -c sqlite3.c -o sqlite3.o 将 5000 更改为您想要的数字.请注意,根据 sqlite3.c 中的注释,您不应使用大于 32676 的数字.
  4. 创建一个静态库来链接:ar crsf libsqlite3.a sqlite3.o
  1. Download amalgamation source code here. It is named sqlite-amalgamation-*.zip
  2. Unzip and change directory inside the unzippped folder. You will see sqlite3.c and sqlite3.h among other files.
  3. Issue this statement to create an object file and setting the desired number of columns: gcc -I. -O3 -DSQLITE_MAX_COLUMN=5000 -c sqlite3.c -o sqlite3.o Change 5000 to the number you desire. Note that, according to the comments in sqlite3.c, you shouldn't use a number greater than 32676.
  4. create a static library to link against: ar crsf libsqlite3.a sqlite3.o

现在,您可以在使用 -lsqlite3 编译程序时链接库,将库放置在链接器知道的位置(或使用 -L/path/to/library).

Now you can link against the library when compiling your program using -lsqlite3, after having placed the library in a location that your linker is aware of (or use -L/path/to/library).

步骤 3) 和 4) 的替代方法.

如果您不想实际创建静态库,而只想在源代码中删除 sqlite3.h 和 sqlite3.c(SQLite 本身建议对它们的合并文件执行此操作),请打开 sqlite3.c 使用您喜欢的编辑器,查找 SQLITE_MAX_COLUMN 并修改其中的值.

If you don't want to actually create the static library but you just want to drop the sqlite3.h and sqlite3.c in your source code (something that SQLite itself suggests doing with their amalgamation files), then open sqlite3.c with your favourite editor, look for SQLITE_MAX_COLUMN and modify the value in there.

我通过 MinGW 使用 gcc 来做到这一点.相同的步骤适用于 MSVC 提供的工具,只是根据需要更改编译和库创建命令.

I used gcc via MinGW to do this. The same steps apply to the tools offered by MSVC, just changing the commands for compilation and library creation as appropriate.

这篇关于SQLITE3 增加最大列数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆