MySQL Queriable Field Constraint by RegEx

2019-09-13 06:58发布

问题:

In addition to a data type of VARCHAR(255), I'd like to add a constraint to the data by a regular expression, e.g. [a-zA-Z ].

I'd like to be able to query the regex, like how I can query meta data in the information_schema.

I've seen some related posts, but not exactly what I'm looking for. I've seen: Restrict varchar() column to specific values? which shows how to use constaints, and I've seen via triggers here: Is it Possible to Enforce Data Checking in MySQL using Regular expression

Can RegExs be used as constraints and those constraints be queried? If so, how?