> Le 30 juin 2018 à 09:04, Thomas Kurz <sqlite.2...@t-net.ruhr> a écrit :
> 
>> a) COLUMN xy VARCHAR(50)
>> b) COLUMN xy MEDIUMTEXT
>> c) COLUMN xy BIT
>> d) COLUMN xy DECIMAL(5,2)
>> Should those raise errors? Because to SQLite those are the exact same 
>> gibberish as:
> 
> I would appreciate if SQLite raised an error each time the declaration 
> mismatches the interpretation. In your example, all declarations are 
> well-known SQL. And, if I understand correctly, SQLite treats each of those 
> as NUMERIC.

I think you don't.
The rules are simple: 
https://www.sqlite.org/datatype3.html#determination_of_column_affinity

> So:
> a) Yes, error, as I indent to store strings, but SQLite uses numbers.

Wrong. VARCHAR has CHAR in the name, SQLite uses TEXT affinity, which match 
perfectly.

> b) Yes, error, same case.

Wrong. MEDIUMTEXT has TEXT in the name, SQLite uses TEXT affinity, which match 
perfectly.

> c) Preferably yes, but not mandatory, as BIT is compatible to NUMERIC

If BIT was to be refused, then would DATE and BOOLEAN for instance. The three 
of them have the convenience to lean to NUMERIC storage thanks to affinity 
rules and it is perfectly fine when you have understood and agreed before 
choosing to use SQLite, that SQLite only uses 4 basic types (let's name them 
INT, REAL, TEXT, BLOB) and that any type wording used in declaration is 
meaningless except that it leads to a type affinity for the column.

> d) No, as DECIMAL ist compatible to NUMERIC.

Fine.

-- 
Best Regards, Meilleures salutations, Met vriendelijke groeten,
Olivier Mascia


_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to