Sqlite> select mycolumn, typeof(mycolumn) from foo Īnd some that will fail: sqlite> INSERT INTO foo VALUES("-1") īut,if you want to store a bunch of them you could bit-shift them and store them all as one int, a little like unix file permissions/modes.įor mode 755 for instance, each digit refers to a different class of users: owner, group, public. Here are some example INSERTs that will work: (note how strings and floating point numbers are parsed as integers) sqlite> INSERT INTO foo VALUES(0) Note that CHECK constraints have been supported since SQLite 3.3.0 (2006). The use of the type name BOOLEAN here is for readability, to SQLite it's just a type with NUMERIC affinity. Omit the NOT NULL if you want to allow NULL in addition to 0 and 1. You could declare the column type like this: CREATE TABLE foo(mycolumn BOOLEAN NOT NULL CHECK (mycolumn IN (0, 1))) In SQLite the best you can do is use the integers 0 and 1 to represent false and true.
0 Comments
Leave a Reply. |