問題描述
有沒有辦法在 SQLite 中定義包含 SQLite 支持的任何數(shù)據(jù)類型的列類型?
Is there a way to define a column type in SQLite that holds any datatype that SQLite supports?
我有無符號字符、有符號字符、無符號整數(shù)、有符號整數(shù)、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 有一個獨特的動態(tài)類型系統(tǒng).它具有按值類型,但如果您指定列類型,SQLite 將確定類型關聯(lián)(TEXT、NUMERIC、INTEGER、REAL、NONE).然后它嘗試將每個值強制為該關聯(lián).
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 中的數(shù)據(jù)類型.
The actual supported types are NULL, INTEGER, REAL, TEXT, BLOB. See Datatypes in SQLite Version 3 for more information.
這篇關于定義“變體"SQLite 中的列類型?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!