How do you preserve a raw field's type inside a STRICT table?
An ANY column in a STRICT table preserves the incoming storage type, useful for data awaiting interpretation.
SQLite example and interpretation
Raw tag 0009 remains four characters. If the importer parses it as an integer first, the database cannot reconstruct its spelling.
CREATE TABLE raw(v ANY) STRICT;
INSERT INTO raw VALUES('0009');
SELECT typeof(v),v FROM raw;Result [["text", "0009"]]
中文
如何在严格类型表里保留原始字段的文本形式?
STRICT 表的 ANY 列能按传入的存储类型保留值,适合保存需要稍后解析的原始数据。
SQLite 示例与适用条件
原始标签 0009 可保留为四字符文本。如果导入程序先将它解析为整数,数据库已无法重建原来的拼写。
CREATE TABLE raw(v ANY) STRICT;
INSERT INTO raw VALUES('0009');
SELECT typeof(v),v FROM raw;结果 [["text", "0009"]]