Jürgen K.
Jürgen K.

Reputation: 3487

SQLite fixed size varchar length check possibly redundant?

Let's first have a look at the following table:

create table SOME_TABLE_NAME(
    Column varchar(3) primary key check(
        Column glob'[A-Z][A-Z][A-Z]'
        and length(Column) = 3)
);

In our create statement we say that our Column consists of not more than characters as maximum. Via glob we check that all 3 characters are letters. Do we still need to check that its length is 3 or is the length check redundant?

Thanks in advance!

Upvotes: 0

Views: 149

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521409

The COLUMN GLOB '[A-Z][A-Z][A-Z]' clause already asserts that primary key consists of exactly three letters, so adding the explicit length check on top of that is redundant.

Upvotes: 2

Related Questions