What Is the Data Type in SQLite?


Larry Thompson

SQLite is a powerful and lightweight relational database management system that is widely used in various applications and platforms. One important aspect of SQLite is its support for different data types, which allows developers to store and manipulate data effectively. In this article, we will explore the various data types available in SQLite and understand their significance.

Data Types in SQLite

SQLite provides a set of built-in data types that can be used to define columns in database tables. These data types determine the nature of the values that can be stored in a particular column. Here are some commonly used data types in SQLite:


The NULL type represents a missing or unknown value. Columns with this data type can store no value or a special null value.


The INTEGER type is used to store whole numbers (integers) without any fractional component. It can hold both positive and negative values.


The REAL type is used to store floating-point numbers with decimal places. It represents both positive and negative values.


The TEXT type is used to store alphanumeric characters, strings, and text values. It can hold any valid Unicode character.


The BLOB (Binary Large Object) type is used to store binary data such as images, documents, or other non-textual information.

Data Type Affinity

In SQLite, each column has an affinity associated with its declared data type. The affinity determines how values are stored and compared in the column. SQLite uses a set of rules to determine the affinity based on the declared data type, but it also allows implicit conversions between different types.

The affinity rules in SQLite are as follows:

  • NULL affinity: Columns declared with no specific type are assigned NULL affinity.
  • INTEGER affinity: Columns declared with an exact integer type (e.g., INTEGER or BIGINT) have INTEGER affinity.
  • REAL affinity: Columns declared with a floating-point or real number type have REAL affinity.
  • TEXT affinity: Columns declared with a text-like data type (e., TEXT, VARCHAR, or CHAR) have TEXT affinity.
  • BLOB affinity: Columns declared with a binary data type have BLOB affinity.

The data type affinities mainly affect how comparisons and sorting operations are performed on the values stored in the columns. It is important to choose the appropriate data type and understand its implications for efficient querying and manipulation of data.

Data Type Examples

To illustrate the usage of different data types in SQLite, let’s consider some examples:

  • Create a table called ‘Employees’ with columns like ‘ID’ (INTEGER), ‘Name’ (TEXT), ‘Salary’ (REAL), and ‘ProfilePicture’ (BLOB).
  • Insert records into the table by providing values of appropriate data types for each column.
  • Perform queries and operations on the table using SQL statements to retrieve, update, or delete specific records based on their data types.

The correct usage of data types ensures data integrity, improves query performance, and avoids unnecessary conversions or errors when working with the database.


Understanding the various data types in SQLite is essential for effectively organizing and manipulating data in a database. By choosing the appropriate data types for columns, developers can ensure data integrity and optimize performance.

The affinity rules help in handling implicit conversions between different data types. Remember to consider the specific requirements of your application when selecting data types for your SQLite tables.

In this article, we explored the different data types available in SQLite and discussed their significance. We also learned about the affinity rules that determine how values are stored and compared. With this knowledge, you can confidently work with SQLite databases and make informed decisions regarding your data storage needs.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy