We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

SQL Data Types

SQL as a language can support many different data types. However, the types that your database management system (DBMS) supports will depend on which database you choose.

As for SQLite, it supports only the most basic types, and SQLite is what we're using in this course!

SQLite Data Types

Let's go over the data types supported by SQLite and how they're stored.

  1. NULL – Null value.
  2. INTEGER – Signed integer stored in 0, 1, 2, 3, 4, 6, or 8 bytes.
  3. REAL – Floating-point value stored as a 64-bit IEEE floating-point number.
  4. TEXT – Text string stored using the database encoding, most commonly UTF-8.
  5. BLOB – Short for Binary Large Object and typically used for images, audio, or other multimedia.
  6. BOOLEAN – Boolean values are written in SQLite queries as true or false, but are recorded as 1 or 0.

You may notice that we use the REAL data type in this course for some fields representing currency amounts. This is for simplicity.

In the real world, to avoid problems with floating-point math, the best practice is to use INTEGER for currency amounts. The value then represents the smallest denomination. For example, $42.67 would be stored as 4267 (cents).

Boolean Values

It's important to note, SQLite does not have a separate BOOLEAN storage class. Instead, boolean values are stored as integers:

  • 0 = false
  • 1 = true

It's not actually all that weird – boolean values are just binary bits after all!

SQLite will let you write your queries using boolean expressions and true/false keywords, but it will convert the booleans to integers under-the-hood.