Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite does not save string made of zeroes

Tags:

sqlite

I'm using SQLite 3.7.4 (within my c++ app under Ubuntu PP) and when I try to save string like "000000" it saves just one char "0". I tried it in console too - is it feature, or bug? How can I get rid of that?

For example:

CREATE TABLE status (readTime INTEGER, status STRING);
INSERT INTO status (readTime, status) values(1234, "000000");
INSERT INTO status (readTime, status) values(4321, "111111");
SELECT * FROM status;
1234|0
4321|111111
like image 623
shmoula Avatar asked Dec 01 '25 09:12

shmoula


1 Answers

Some quick research points to the fact that STRING is not a recognized type in SQLite (or, I believe, most other SQL dialects). However, SQLite isn't strict with its types, so the type defaulted to NUMERIC. You should be able to change the column type to TEXT to resolve your issue.

Further reading: Type Affinity

like image 146
Seth Anderson Avatar answered Dec 09 '25 08:12

Seth Anderson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!