|
2 | 2 | title: Data types
|
3 | 3 | ms.date: 12/13/2019
|
4 | 4 | description: Describes the supported data types and some of the limitations around them.
|
| 5 | +no-loc: ["INTEGER", "BLOB", "TEXT", "REAL"] |
5 | 6 | ---
|
6 | 7 | # Data types
|
7 | 8 |
|
8 | 9 | SQLite only has four primitive data types: INTEGER, REAL, TEXT, and BLOB. APIs that return database values as an `object` will only ever return one of these four types. Additional .NET types are supported by Microsoft.Data.Sqlite, but values are ultimately coerced between these types and one of the four primitive types.
|
9 | 10 |
|
10 |
| -| .NET | SQLite | Remarks | |
11 |
| -| -------------- | ------- | ------------------------------------------------------------- | |
12 |
| -| Boolean | INTEGER | `0` or `1` | |
13 |
| -| Byte | INTEGER | | |
14 |
| -| Byte[] | BLOB | | |
15 |
| -| Char | TEXT | UTF-8 | |
16 |
| -| DateOnly | TEXT | yyyy-MM-dd | |
17 |
| -| DateTime | TEXT | yyyy-MM-dd HH:mm:ss.FFFFFFF | |
18 |
| -| DateTimeOffset | TEXT | yyyy-MM-dd HH:mm:ss.FFFFFFFzzz | |
19 |
| -| Decimal | TEXT | `0.0###########################` format. REAL would be lossy. | |
20 |
| -| Double | REAL | | |
21 |
| -| Guid | TEXT | 00000000-0000-0000-0000-000000000000 | |
22 |
| -| Int16 | INTEGER | | |
23 |
| -| Int32 | INTEGER | | |
24 |
| -| Int64 | INTEGER | | |
25 |
| -| SByte | INTEGER | | |
26 |
| -| Single | REAL | | |
27 |
| -| String | TEXT | UTF-8 | |
28 |
| -| TimeOnly | TEXT | HH:mm:ss.fffffff | |
29 |
| -| TimeSpan | TEXT | d.hh:mm:ss.fffffff | |
30 |
| -| UInt16 | INTEGER | | |
31 |
| -| UInt32 | INTEGER | | |
32 |
| -| UInt64 | INTEGER | Large values overflow | |
| 11 | +| .NET | SQLite | Remarks | |
| 12 | +| -------------- | ------- | ----------------------------------------------------------------------------------| |
| 13 | +| :::no-loc text="Boolean"::: | INTEGER | `0` or `1` | |
| 14 | +| :::no-loc text="Byte"::: | INTEGER | | |
| 15 | +| :::no-loc text="Byte[] "::: | BLOB | | |
| 16 | +| :::no-loc text="Char"::: | TEXT | UTF-8 | |
| 17 | +| :::no-loc text="DateOnly"::: | TEXT | :::no-loc text="yyyy-MM-dd"::: | |
| 18 | +| :::no-loc text="DateTime"::: | TEXT | :::no-loc text="yyyy-MM-dd HH:mm:ss.FFFFFFF"::: | |
| 19 | +| :::no-loc text="DateTimeOffset"::: | TEXT | :::no-loc text="yyyy-MM-dd HH:mm:ss.FFFFFFFzzz"::: | |
| 20 | +| :::no-loc text="Decimal"::: | TEXT | `0.0###########################` format. REAL would be lossy. | |
| 21 | +| :::no-loc text="Double"::: | REAL | | |
| 22 | +| :::no-loc text="Guid"::: | TEXT | 00000000-0000-0000-0000-000000000000 | |
| 23 | +| :::no-loc text="Int16"::: | INTEGER | | |
| 24 | +| :::no-loc text="Int32"::: | INTEGER | | |
| 25 | +| :::no-loc text="Int64"::: | INTEGER | | |
| 26 | +| :::no-loc text="SByte"::: | INTEGER | | |
| 27 | +| :::no-loc text="Single"::: | REAL | | |
| 28 | +| :::no-loc text="String"::: | TEXT | UTF-8 | |
| 29 | +| :::no-loc text="TimeOnly"::: | TEXT | HH:mm:ss.fffffff | |
| 30 | +| :::no-loc text="TimeSpan"::: | TEXT | d.hh:mm:ss.fffffff | |
| 31 | +| :::no-loc text="UInt16"::: | INTEGER | | |
| 32 | +| :::no-loc text="UInt32"::: | INTEGER | | |
| 33 | +| :::no-loc text="UInt64"::: | INTEGER | Large values overflow | |
33 | 34 |
|
34 | 35 | ## Alternative types
|
35 | 36 |
|
36 | 37 | Some .NET types can be read from alternative SQLite types. Parameters can also be configured to use these alternative types. For more information, see [Parameters](parameters.md#alternative-types).
|
37 | 38 |
|
38 |
| -| .NET | SQLite | Remarks | |
39 |
| -| -------------- | ------- | ---------------- | |
40 |
| -| Char | INTEGER | UTF-16 | |
41 |
| -| DateOnly | REAL | Julian day value | |
42 |
| -| DateTime | REAL | Julian day value | |
43 |
| -| DateTimeOffset | REAL | Julian day value | |
44 |
| -| Guid | BLOB | | |
45 |
| -| TimeOnly | REAL | In days | |
46 |
| -| TimeSpan | REAL | In days | |
| 39 | +| .NET | SQLite | Remarks | |
| 40 | +| -------------- | ------- | ------------------------------------ | |
| 41 | +| :::no-loc text="Char"::: | INTEGER | UTF-16 | |
| 42 | +| :::no-loc text="DateOnly"::: | REAL | Julian day value | |
| 43 | +| :::no-loc text="DateTime"::: | REAL | Julian day value | |
| 44 | +| :::no-loc text="DateTimeOffset"::: | REAL | Julian day value | |
| 45 | +| :::no-loc text="Guid"::: | BLOB | | |
| 46 | +| :::no-loc text="TimeOnly"::: | REAL | In days | |
| 47 | +| :::no-loc text="TimeSpan"::: | REAL | In days | |
47 | 48 |
|
48 | 49 | For example, the following query reads a TimeSpan value from a REAL column in the result set.
|
49 | 50 |
|
|
0 commit comments