Skip to content Skip to sidebar Skip to footer

Sqlite Automatically Converts String To Integer When Inserting Incorrect Types

I am doing some basic sqlite. I have a relation named A. 2 tuples named C,D. The tuples accept integer values. But when I try to insert string values, sqlite still accepts them fo

Solution 1:

SQLite uses dynamic typing; it will accept values of any type.

If you really want the database to check the type, add a CHECK constraint:

CREATE TABLE A(
    C INTEGER CHECK(typeof(C) = 'integer'),
    D INTEGER CHECK(typeof(D) = 'integer')
);

Post a Comment for "Sqlite Automatically Converts String To Integer When Inserting Incorrect Types"