It is currently Sun Oct 25, 2020 2:50 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Sqlite question
PostPosted: Tue Oct 13, 2020 9:17 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Mar 27, 2009 9:41 am
Posts: 754
Location: Athens, Greece
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Sqlite question
PostPosted: Tue Oct 13, 2020 10:20 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Sep 22, 2010 1:17 pm
Posts: 352
Location: United Kingdom
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye