0

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!

Jürgen K.
  • 3,427
  • 9
  • 30
  • 66

1 Answers1

2

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.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • Ok awesome, does it make sense to set the column size since varchar is transferred to TEXT? – Jürgen K. Jul 25 '19 at 15:40
  • 1
    Setting the `varchar` width should not make a difference, since `varchar` has an affinity for `text`, and `text` has no real limit, except for `SQLITE_MAX_LENGTH`. [See this SO question](https://stackoverflow.com/questions/17785047/string-storage-size-in-sqlite) for a discussion on this. – Tim Biegeleisen Jul 25 '19 at 15:43