Thanks Peter, that's exactly what I wanted. I've gone with your first
(more strict) solution.
Cheers.
Date: Sat, 02 Aug 2014 22:42:41 -0700
From: Peter Aronson
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Prevent non-Integers going into int fields.
Message-ID: <53ddcbd1.60
If you don't mind requiring that the value being inserted be typed
integer, you can use:
create table t1 (c1 integer check (typeof(c1) = 'integer'));
But this means that values that could be converted to integers by the
integer affinity of the column, like 4.0 or '1' will be cause a check
con
Whilst any type going into a field is often seen as a big plus, there are
occasions where this may be undesirable.
For such occasions, I'm currently thinking that:
NOT NULL CHECK( ROUND(fieldname)=fieldname )
looks ok, but I'm wondering if there's a case that still gets through or if
there's a be
3 matches
Mail list logo