Sqlite question
- doctorized
- Addict

- Posts: 882
- Joined: Fri Mar 27, 2009 9:41 am
- Location: Athens, Greece
Sqlite question
First of all, I am not very familiar with sqlite. In a SQLite db I have defined: Grade CHAR(3) (it was supposed to store integer values 0 to 10 or a letter, like A, B, C, etc). I noticed that a value like "8.12345" or "katana" can be stored and the table doesn't seem to be altered by some overflow. How is it possible? The value stored is defined as grage.s, that means it should be stored "8.1" or "kat" and not "8.12345" or "katana". What am I missing? I did a google search but didn't help.
Re: Sqlite question
SQLite accepts types in schemas but doesn't rigidly enforce them in queries and updates.
If you insert/update something that doesn't match the column's defined type - it can and will store it without complaint.
If you want to impose rigid type definitions your application must implement them.
The only exception is an INTEGER PRIMARY KEY column, which is an alias for the internal RowID and must be enforced.
See https://www.sqlite.org/datatype3.html
If you insert/update something that doesn't match the column's defined type - it can and will store it without complaint.
If you want to impose rigid type definitions your application must implement them.
The only exception is an INTEGER PRIMARY KEY column, which is an alias for the internal RowID and must be enforced.
See https://www.sqlite.org/datatype3.html
