问题描述
有没有办法在 SQLite 中定义包含 SQLite 支持的任何数据类型的列类型?
Is there a way to define a column type in SQLite that holds any datatype that SQLite supports?
我有无符号字符、有符号字符、无符号整数、有符号整数、UTF-8 字符和 blob,我想将它们填充到单个列中.
I have unsigned chars, signedchars, unsigned ints, signed ints, UTF-8 chars and blobs that I want to populate in a single column.
也欢迎参考任何文献.
推荐答案
只是不要在列声明中放类型,所以它没有亲和性
Just don't put a type in the column declaration, so it has NONE affinity
create table my_table(my_col);
SQLite 有一个独特的动态类型系统.它具有按值类型,但如果您指定列类型,SQLite 将确定类型关联(TEXT、NUMERIC、INTEGER、REAL、NONE).然后它尝试将每个值强制为该关联.
SQLite has a unique dynamic typing system. It has per-value typing, but if you specify a column type, SQLite will determine a type affinity (TEXT, NUMERIC, INTEGER, REAL, NONE). It then attempts to coerce each value to that affinity.
实际支持的类型有 NULL、INTEGER、REAL、TEXT、BLOB.有关详细信息,请参阅 SQLite 版本 3 中的数据类型.
The actual supported types are NULL, INTEGER, REAL, TEXT, BLOB. See Datatypes in SQLite Version 3 for more information.
这篇关于定义“变体"SQLite 中的列类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!