SQLite Forum

Doc enhancements for new release
Login
> Care to propose a better qualifier?

Nope, I'm agreeing with your assessment - thank you for it.  

Here is the part I wanted to improve clarity on but failed miserably to do:

A TABLE constraint is declared after the columns and if it contains a reference to the column being dropped, then sure enough that is an error (the original text makes this part clear enough).

The original "However" text following that suggests: If the constraint referencing the column is a COLUMN constraint, i.e. declared as part of a column, then it is allowed to be dropped because the constraint will fizzle together with the column.

BUT there is a logic error - if the constraint *IS* a column constraint but as part of another column than the one being dropped, it will still FAIL even though it is a "COLUMN" constraint.  

By way of Example:

```
-- Declaring a table t with only 1 column constraint, no table constraints:

CREATE TABLE t(
  x INT NOT NULL,
  y INT CHECK (y > x)
);
```
Dropping column y - no problem.  
Dropping column x - problem - will FAIL.


So I think we should make clear that the drop will fail if:

- The column appears in ANY TABLE-constraint,  
  OR
- The column appears in ANY COLUMN-constraint when declared in another column than the one being dropped.

If the column is referenced in any constraint, it will succeed if, and only if, that constraint is a COLUMN constraint of specifically ITSELF.


Allow me to re-attempt a suitable description:


Original:  
"The column appears in a table CHECK constraint. However, the column being deleted can be used in a column CHECK constraint because the column CHECK constraint is dropped together with the column itself."

New Suggestion:  
"The column appears in a table CHECK constraint or a column CHECK constraint of another column. A CHECK constraint declared on the column itself will not prevent it since that constraint will be dropped with the column."


I'm still not loving it 100% - Perhaps someone here with better English skills than myself could assist with a better-sounding phrase that is both accurate and succinct.