1

Consider the following minimal example.

CREATE TABLE Student (
  Name varchar(50),
  CHECK (isEnglish(Name))
)

I want to add a constraint that the name is in the English alphabet (a-z, A-Z) while inserting a new tuple in the STUDENT table. How do I do this? That is, what should I put in place of isEnglish(Name)?

  • 1
    Does this answer your question? [Is it Possible to Enforce Data Checking in MySQL using Regular expression](https://stackoverflow.com/questions/16005283/is-it-possible-to-enforce-data-checking-in-mysql-using-regular-expression) – Tobias S. Oct 23 '21 at 14:25

1 Answers1

4

Hope this helps but only works on MySQL 8.0

CREATE TABLE Student (
  Name varchar(50) CHECK (Name REGEXP '^[A-Za-z]+$')
)
rosh-dev851
  • 534
  • 4
  • 8