SQLDatabase.Net - Data Types

Data type is an attribute that specifies the type of data for any given column. Each column and expression has related data type. Library supports the concept of type affinity on columns rather than storage data type. In simple words it means any column can store any type of data but the preferred storage type for a column is called its affinity.

It only supports five (5) datatypes which are rather generic and these are mapped to actual data types.

List of Data Types

# Storage Type Description
1 NULL

The value is a NULL value.

2 INTEGER

The value is a signed integer, stored in 1, 2, 3, 4, 6, or 12 bytes depending on the size of the value. Int64 is used to read and write.

3 REAL

The value is a floating point value, stored as an 8-byte IEEE floating point number.

4 TEXT

The value is a text string, stored using the unicode encoding (UTF-8)

5 BLOB

The value is a blob of data, stored exactly as it was input using binary or System.Byte array.

Data Type Description

# Affinity Description
1 TEXT

This column stores all data using storage type of NULL, TEXT or BLOB in unicode.

2 BLOB

This column may contain values using all five storage classes.

3 INTEGER

Behaves the same as a column which can store numbers.

4 REAL

Behaves like a column with .Net Double or Decimal, since it forces integer values into floating point representation.

5 NONE

A column with affinity NONE does not prefer one storage class over another and no attempt is made to coerce data from one storage class into another.


Boolean Datatype is supported throught integer datatype. Boolean values are stored as integers 0 (false) and 1 (true).

Date Time Datatype is supported through following storage types, on file dates and times are stored as TEXT, REAL or INTEGER values.

# Storage Type Date Formate
1 TEXT

A date in a format like "YYYY-MM-DD HH:MM:SS.SSS"

2 REAL

The number of days since noon in Greenwich on November 24, 4714 B.C.

3 INTEGER

The number of seconds since 1970-01-01 00:00:00 UTC

You can choose to store date and time in any of these formats and freely convert between formats using the built-in date and time functions.