SQLite Forum

CHECK violation during table definition ignored, normal or bug?
Login
You can achieve this by doing the following, for example:

```
sqlite> create table t
   ...> (
   ...> a integer,
   ...> b integer constraint "t(b)" check (c > 4),
   ...> c integer constraint "t(c)" check (b < 2)
   ...> );
```

though I would note that this is rather confusing, but if that is how you want to do things, then you are of course free to do so.

Personally I should think that having the constraint named in such fashion as to indicate the constraint itself would be more rational and it should be noted that the exact same person as creates the check constraint also has control over what the constraint is named and that if this person deliberately chooses not to name the constraint then that is their decision.

I would note that your entire thesis is ill-conceived given that *ALL* check constraints are *TABLE CONSTRAINTS* even though they may be syntactically (though not semantically) spoken as part of the column definition.

It would perhaps be rational to request that if no constraint name was specified that the default name should be the SPAN of the expression composing the constraint.  I have no idea if the SPAN data is maintained (as it is for example for the column default) but this would only be a rather small parser change I should think.