SQLite Forum

Triggers
Login
Adding a Trigger to do something, almost anything really, upon inserting (or update or delete etc.) is trivial.
[This documentation should get you there easily.](https://sqlite.org/lang_createtrigger.html)

Contrary to the Anonymous poster's assertion, I believe their proposed CHECK constraint is indeed many times more efficient, if for no other reason than running the "SUBSTR()" function many times less.

Another side-note - your other CHECK constraint, namely:  
```
  CHECK (VIN NOT LIKE '%I%' OR VIN NOT LIKE '%O%' OR VIN NOT LIKE '%Q%')  
```
is almost guaranteed to not be correct. It will succeed on ANY combination of those Q, O and I characters, except in the explicit case when they are ALL 3 present in the same VIN. This *could* be the intent, but seems unlikely.
Did you perhaps mean:  
```
  CHECK (VIN NOT LIKE '%I%' AND VIN NOT LIKE '%O%' AND VIN NOT LIKE '%Q%')  
```
which changes the meaning to "Do not allow entries containing any 'Q' or 'O' or 'I'." - which feels to me like the intent - but I could of course be wrong.

Good luck!