SQL 不同的数据类型
SQL 不同的数据类型
1、SQL TEXT
2、SQL VARCHAR(SIZE)
VARCHAR(X)
Case: user name, email, country, subject, password
TEXT
Case: messages, emails, comments, formatted text, html, code, images, links
MEDIUMTEXT
Case: large json bodies, short to medium length books, csv strings
LONGTEXT
Case: textbooks, programs, years of logs files, harry potter and the goblet of fire, scientific research logging
REFER: MySQL: TEXT vs. VARCHAR Performance
REFER: Datatypes In SQLite Version 3
3、SQLITE Datatype
Most SQL database engines (every SQL database engine other than SQLite, as far as we know) uses static, rigid typing. With static typing, the datatype of a value is determined by its container - the particular column in which the value is stored.
大部分SQL database engies(迄今为止,除了SQLITE之外的 database engine) 使用 static/静态的, rigid-typing/严格 typing的。 使用 static-typing,某个值的 datatype/数据类型 由其所在的 container/容器 定义。
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 statements 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 使用一种 比较通用的 动态类型系统/dynamic-type-system. 在 SQLITE中,值的 datatype 是和 值本身 密切相关的,而不是其所在的容器。SQLITE中的动态类型系统 与 传统的 static-type 后向兼容/backwards-compatible,也就是说 可以在 static-typed-database工作的 SQL-statements 同样可以在 SQLITE 中使用。
Each value stored in an SQLite database (or manipulated by the database engine) has one of the following storage classes:
存储在SQLITE-database 中的所有值 都有下面一种 storage-class/存储类???。
NULL. The value is a NULL value.
INTEGER. The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value.
REAL. The value is a floating point value, stored as an 8-byte IEEE floating point number.
TEXT. The value is a text string, stored using the database encoding (UTF-8, UTF-16BE or UTF-16LE).
BLOB. The value is a blob of data, stored exactly as it was input.
参考: