---
title: "SQLite is not weakly typed!"
url: "https://aaronfrancis.com/videos/sqlite-is-not-weakly-typed"
path: "/videos/sqlite-is-not-weakly-typed"
type: video
author: Aaron Francis
published: 2024-06-11
topic: Databases
keywords: [sqlite, sqlite type system, sqlite strict tables, sqlite type safety, sqlite schema, sqlite column types, sqlite constraints, dynamic typing, high performance sqlite]
youtube_url: "https://www.youtube.com/watch?v=sgVpOaJLoG0"
site_index: "/llms.txt"
keyword_index: "/llms/keywords.txt"
---

# SQLite is not weakly typed!

## Chapters

- SQLite is Flexibly Typed
- Storing Multiple Types in Column
- Use Cases for Multiple Types in Column
- Strict Tables
- Strict Table with Strict and Flexible Columns

## Transcript

**Aaron Francis:** One of the things that you will hear about SQLite all the time is that SQLite is weakly typed, which is a little bit derogatory. For goodness sakes, it's flexibly typed. It's not weak, it's flexible. So the column types in SQLite are just merely suggestions. You can suggest what should go in there, but it will allow anything in there, unless you use a strict table.

**Aaron Francis:** Let's start with a non-strict table. If we create a table, let's do create table types, and we'll say that N is an integer, and we insert into types values one. What do you think's gonna happen? That's right. Select star from types. That sure is ugly. Let's do mode of box.

**Aaron Francis:** Whoops. Mode of box, and clear that out, and select again N of one. Perfect. Let's do select N and type of N from types. What do you think we get? Integer. Good so far. However, let's clear that out. Insert into types a value of hello, and that is wrong, because I forgot values, values hello.

**Aaron Francis:** So if we clear that out and select... Uh-oh. Now we have a text value in an integer column. You can put whatever you want in a SQLite column in a traditional table. We'll look at a strict table here in a second. Let's look at one more thing. If you were to insert into types values of 1.0, I want you to tell me what you think is gonna come back here.

**Aaron Francis:** Is it gonna store a float or a real or a double, or is it gonna store an integer? Are you ready? Do you have your answers ready? Here we go. Stored an integer. That's interesting. Let's try it again. Uh, 1.1. What do you think? Do you have your answers ready? Let's clear this out, and here we go.

**Aaron Francis:** Ah, that one stored a real. That sure is interesting. So the rule that we are intuiting here is that if SQLite can convert the input that you give it into the type that is suggested for that column without losing data, then it will. So in this case, when we inserted 1.0, it said, "I can convert that to an integer without losing data." However, 1.1, you can't just drop the .1.

**Aaron Francis:** That's valuable data, and so it just puts it in as a real. Is this a good or a bad thing? I don't know. It is a thing, though. If this is what you want, it's a good thing. If this is behavior you're not expecting, it's probably a bad thing. There are some places where this would be really valuable. You can imagine creating a key value store out of SQLite, and the value can be anything.

**Aaron Francis:** It can be a number, it can be a string, it could be a blob, it could be anything. That's, that's really helpful. You can imagine loading a CSV file into SQLite, and people that create CSV files don't always adhere to strict database rules, and they might, they might put some random stuff in there. That can be really useful. If, for whatever reason, you're using the entity attribute value paradigm, or let's take a better paradigm, user settings, and some settings are integers and some settings are

**Aaron Francis:** strings, this would be a great use case for that. What if you hate it? What if you freaking hate it, and you're like, "I want strict tables." We can do that. Let's take a look. If we were to create a table... So let's do, let's do another one. Let's do create table types two. I just came up with that name right off the spot.

**Aaron Francis:** Types two. N is an integer, and we append this keyword strict at the end. There you go. Now we've got a strict table. Insert into types two values of one. Ooh, we're all good. All right. Insert into types two value of hello. Type it out, come on. There we go.

**Aaron Francis:** Cannot store a text value in an integer column. SQLite has strict typing. But what if, what if you now have strict types and you're like, "You know what? I love strict types. I also want flexible types." Golly, you guys, you can have it all. You can have it all with SQLite.

**Aaron Francis:** Let's create a table called types three. Again, right off the spot. N, uh, integer, and we'll say, um, value, we can just call it value, is any. So now we can declare a strict table, but have a flexible column.

**Aaron Francis:** So we can insert into types three values is one and one, and insert into types three one and hello, and one and... Should change that from one to one to 3.1. Select star from types three.

**Aaron Francis:** That's ugly. Mode box. Select star from types three. So now N is strict and value is declared as an any, so you can put any thing that you want into that column. The next time you hear the haters say that SQLite is weakly typed, tell them that it's flexibly typed, and it could be strict type if you want.

**Aaron Francis:** If you wanna learn more about SQLite, I do have a course coming up called High Performance SQLite. If you wanna run SQLite in production, I encourage you to check out Turso. Until the next time, see ya.

---

## Related on aaronfrancis.com

- [SQLite is not weakly typed!](/writing/sqlite-is-not-weakly-typed) *(Article · 2024-09-23 · shared: sqlite, sqlite type system, sqlite strict tables)*
- [About](/about) *(Page · 2026-11-25 · shared: sqlite, high performance sqlite)*
- [Laravel's Big Day](/podcast/laravels-big-day-959237a1) *(Podcast · 2025-02-27 · shared: high performance sqlite, sqlite)*
- [Aaron Francis: Laravel Solo, Courses, Screen casting](/podcast/aaron-francis-laravel-solo-courses-screen-casting-e1626b9b) *(Podcast · 2024-12-20 · shared: high performance sqlite, sqlite)*
- [High Performance SQLite](/courses) *(Course · 2024-07-01 · shared: sqlite, sqlite schema)*

## Relevant Resources from Aaron Francis

- **[MySQL for Developers](https://databaseschool.com)** (overview on site: [/courses](/courses)): Full video course covering MySQL indexing, deferred joins, pagination, query plans, and schema design for application developers.
- **[High Performance SQLite](https://databaseschool.com)** (overview on site: [/courses](/courses)): Comprehensive video course on running SQLite in production: WAL mode, concurrency, FTS5, strict tables, backups, and performance tuning.

## Search aaronfrancis.com (2-Hop Static Keyword Index)

Pick the alphabetical shard matching any topic to find exact pages across all articles, newsletters, videos, talks, and podcast transcripts (every shard is < 40 KB):
[A-B](/llms/keywords/a-b.txt) · [C](/llms/keywords/c.txt) · [D-E](/llms/keywords/d-e.txt) · [F-G](/llms/keywords/f-g.txt) · [H-J](/llms/keywords/h-j.txt) · [K-L](/llms/keywords/k-l.txt) · [M-N](/llms/keywords/m-n.txt) · [O-P](/llms/keywords/o-p.txt) · [Q-R](/llms/keywords/q-r.txt) · [S](/llms/keywords/s.txt) · [T-Z](/llms/keywords/t-z.txt) · [Directory](/llms/keywords.txt) · [Site Map](/llms.txt)

Shards for this page's topics: `sqlite` ([S](/llms/keywords/s.txt)), `dynamic typing` ([D-E](/llms/keywords/d-e.txt)), `high performance sqlite` ([H-J](/llms/keywords/h-j.txt)).

## About Aaron Francis (Current Context)

Aaron Francis is VP of Marketing and Community at [Laravel](https://laravel.com), founder of [Try Hard Studios](https://tryhardstudios.com), creator of [Solo](https://soloterm.com), co-host of [Mostly Technical](/podcast), and author of [Mastering Postgres](/courses), [High Performance SQLite](/courses), [MySQL for Developers](/courses), and [Screencasting.com](/courses). Full bio: [/about](/about) · Current focus: [/now](/now).
