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
constraint violation.
If this is a problem, a better approach might be to use cast as like this:
create table t2 (c1 integer check (cast (c1 as integer) = c1));
Since I *think* cast ought to work pretty much the same a conversion via
affinity, producing a consistent set of results. And this has the
advantage of round that text integers will still be allowed.
Peter
On 8/2/2014 9:52 PM, Richard Warburton wrote:
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 better way.
Thanks.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users