SQL SQLite3 整数最大值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4448284/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SQLite3 Integer Max Value
提问by nicholas
- what is the maximum value of data type INTEGER in sqlite3 ?
- How do you store ip address in database ?
- What is attached ?
- How to create table which belongs to a specific database using sql ddl?
- What is this error about ?
- sqlite3 中数据类型 INTEGER 的最大值是多少?
- 你如何在数据库中存储IP地址?
- 附什么?
- 如何使用sql ddl创建属于特定数据库的表?
- 这个错误是关于什么的?
error while the list of system catalogue : no such table: temp.sqlite_master Unable to execute statement
系统目录列表时出错:没有这样的表:temp.sqlite_master 无法执行语句
- Does sqlite3 text data type supoports unicode? Thanks.
- sqlite3 文本数据类型是否支持 unicode?谢谢。
回答by Gabriele Petrioli
- Look at http://www.sqlite.org/datatype3.htmlMinimum is -(263) == -9223372036854775808 and maximum is 263- 1 == 9223372036854775807
- I would think you should use a varchar
- http://www.sqlite.org/lang_attach.html
- http://www.sqlite.org/lang_createtable.html
- might be of help SQLite 'no such table' error
- 查看http://www.sqlite.org/datatype3.html最小值是 -(2 63) == -9223372036854775808 最大值是 2 63- 1 == 9223372036854775807
- 我认为你应该使用 varchar
- http://www.sqlite.org/lang_attach.html
- http://www.sqlite.org/lang_createtable.html
- 可能对SQLite 'no such table' 错误有所帮助
in general check out the sqlite documentation
一般检查sqlite文档
回答by dheerosaur
INTEGER. The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value.
The INTEGER storage class, for example, includes 6 different integer datatypes of different lengths. This makes a difference on disk. But as soon as INTEGER values are read off of disk and into memory for processing, they are converted to the most general datatype (8-byte signed integer).
整数。该值是一个有符号整数,根据值的大小存储在 1、2、3、4、6 或 8 个字节中。
例如,INTEGER 存储类包括 6 种不同长度的不同整数数据类型。这在磁盘上有所不同。但是一旦从磁盘读取 INTEGER 值并进入内存进行处理,它们就会转换为最通用的数据类型(8 字节有符号整数)。
from http://www.sqlite.org/datatype3.html
来自http://www.sqlite.org/datatype3.html
Unless you have some other reason not to, you can store IP address using TEXT.
除非您有其他原因不这样做,否则您可以使用 TEXT 存储 IP 地址。
回答by bezmax
Regarding the second question:
关于第二个问题:
You can store IP address in DB in 2 ways:
您可以通过两种方式在 DB 中存储 IP 地址:
- As a String. This is recommended as it will support both IPv4 and IPv6 and does not require no additional hassle with IP address conversions.
- As an integer. IP is basically 4 bytes that can all be merged into one integer value. However, do you really want that? That will give you loads of pain converting it to/from string any time it is required.
- 作为字符串。建议这样做,因为它将支持 IPv4 和 IPv6,并且不需要额外的 IP 地址转换麻烦。
- 作为整数。IP 基本上是 4 个字节,可以全部合并为一个整数值。然而,你真的想要吗?这会给您带来大量的痛苦,无论何时需要将其转换为字符串或从字符串转换。
回答by Donal Fellows
- How do you store ip address in database ?
- 你如何在数据库中存储IP地址?
The easiest way is to store the string form (e.g., “127.0.0.1
” or “::1
”) since then you can read them manually and reparsing to an address structure (if you have to) is easy. SQLite likes strings (which use the TEXT type) and handles them efficiently.
最简单的方法是存储字符串形式(例如“ 127.0.0.1
”或“ ::1
”),这样您就可以手动读取它们并且重新解析为地址结构(如果必须)很容易。SQLite 喜欢字符串(使用 TEXT 类型)并有效地处理它们。
回答by dan04
Does sqlite3 text data type supports unicode?
sqlite3 文本数据类型是否支持 unicode?
Yes and no.
是和否。
Yes in that SQLite lets you store TEXT
data in UTF-8 or UTF-16. (Use PRAGMA ENCODINGto choose the internal format.)
是的,因为 SQLite 允许您TEXT
以 UTF-8 或 UTF-16存储数据。(使用PRAGMA ENCODING选择内部格式。)
No in that the built-in LOWER
and UPPER
functions only affect ASCII characters. But you can redefine functionsand collationsto add this support. There's an ICU extensionto SQLite that does this.
不,因为内置函数LOWER
和UPPER
函数只影响 ASCII 字符。但是您可以重新定义函数和排序规则以添加此支持。SQLite有一个ICU 扩展可以做到这一点。