I'm starting a series of short notes about handy SQLite features you may not have heard about. The first one is

Modern SQLite #1: STRICT tables

submited by
Style Pass
2024-05-04 14:00:06

I'm starting a series of short notes about handy SQLite features you may not have heard about. The first one is "strict" tables.

As you probably know, SQLite's type system is very flexible (some people even call SQLite the JavaScript of databases) — you can store any value in any column type (e.g. create an INTEGER column and store text values there, or a REAL with blob values).

Some people love SQLite for its flexibility, others hate it for the same reason. So at some point the SQLite authors introduced STRICT tables:

Even with strict tables, you can still explicitly declare a column as ANY — such columns can hold values of any type. So you can have the best of both worlds — strict type checking and type flexibility:

Interactive examples in this post are powered by codapi — an open source tool I'm building. Use it to embed live code snippets into your product docs, online course or blog.

Leave a Comment