defining a quot;VARIANTquot; column type in SQLite?(定义“变体SQLite 中的列类型?)
问题描述
有没有办法在 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 中的列类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:定义“变体"SQLite 中的列类型?
基础教程推荐
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 在多列上分布任意行 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
