gpt4 book ai didi

sqlite 中的字符串数据类型

转载 作者:行者123 更新时间:2023-12-03 17:28:18 28 4
gpt4 key购买 nike

我创建了一个表如下:

create table employers (
id integer primary key,
name string,
surname string,
description string
);

我注意到了 here string 不在数据类型之间,我应该用其他东西替换它吗?它是其他数据类型的别名吗?这个字符串最多可以包含多少个字符?

我使用了 string 并且它没有产生任何问题。我只感兴趣怎么可能,我可以使用 string.是别名吗?这种类型的可能性有哪些?

谢谢

最佳答案

您想使用 TEXT,我们会根据需要使用它来保存您的数据。

CREATE TABLE Employers (
id INTEGER PRIMARY KEY,
name TEXT,
surname TEXT,
description TEXT
);

参见 http://www.sqlite.org/datatype3.html 并注意:

SQLite uses a more general dynamic type system. In SQLite, the datatype of a value is associated with the value itself, not with its container. The dynamic type system of SQLite is backwards compatible with the more common static type systems of other database engines in the sense that SQL statement that work on statically typed databases should work the same way in SQLite. However, the dynamic typing in SQLite allows it to do things which are not possible in traditional rigidly typed databases.

指出:

SQLite does not impose any length restrictions (other than the large global SQLITE_MAX_LENGTH limit) on the length of strings, BLOBs or numeric values.

最后:

Maximum length of a string or BLOB

The maximum number of bytes in a string or BLOB in SQLite is defined by the preprocessor macro SQLITE_MAX_LENGTH. The default value of this macro is 1 billion (1 thousand million or 1,000,000,000). You can raise or lower this value at compile-time using a command-line option like this:

-DSQLITE_MAX_LENGTH=123456789 The current implementation will only support a string or BLOB length up to 231-1 or 2147483647. And some built-in functions such as hex() might fail well before that point. In security-sensitive applications it is best not to try to increase the maximum string and blob length. In fact, you might do well to lower the maximum string and blob length to something more in the range of a few million if that is possible.

During part of SQLite's INSERT and SELECT processing, the complete content of each row in the database is encoded as a single BLOB. So the SQLITE_MAX_LENGTH parameter also determines the maximum number of bytes in a row.

The maximum string or BLOB length can be lowered at run-time using the sqlite3_limit(db,SQLITE_LIMIT_LENGTH,size) interface.

关于sqlite 中的字符串数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6115212/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com