SQLite Forum

Constraint Name
A constraint name is used to give a name to a constraint.  Sometimes when a constraint is violated its name is reported to help you determine the error of your ways.

Just because you **can** do a thing, does not mean you **must** do a thing, nor does it mean that it would be **useful** to do a thing.

It might not be useful to have a constraint name on a default, not null, or collate either.  Yet there you have it, you can assign a constraint name to these things also if you wish.

The fact of the matter is that they are constraints on the value of a column and therefore may be given a name.  The fact that you can give column constrains a name if you choose to do so is quite independent of the utility of doing so.

Some people are in love with giving everything a label/name, just as some people are in love with using ill-conceived character sequences in identifiers, and still other are in love with using identifier quotes even when not needed; some are in love with extraneous parenthesis, and some in love with making everything a left join when they mean equi-join; there are even some people are in love with prefixing column names with the name of the table containing the column despite the fact that the scope of a column name is the table in which it is declared.

There is no explanation for why people do the things they do.  It just is.

However, on the other hand, the very definition of **column constraint** as a generic thing permits them to have names.  Dividing the class **column constraint** into two classes simply to avoid the optional capability that a **column constraint** can be given a name increases complexity yet provides zero additional capability since one can already choose to not give a **column constraint** a name.