Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it Possible to Enforce Data Checking in MySQL using Regular expression

Suppose I have an attribute called phone number and I would like to enforce certain validity on the entries to this field. Can I use regular expression for this purpose, since Regular Expression is very flexible at defining constraints.

like image 945
Shamim Hafiz - MSFT Avatar asked Apr 14 '13 22:04

Shamim Hafiz - MSFT


1 Answers

MySQL 8.0.16 (2019-04-25) and MariaDB 10.2.1 (2016-04-18) now not only parse CHECK constraint but also enforces it.

MySQL: https://dev.mysql.com/doc/refman/8.0/en/create-table-check-constraints.html

MariaDB: https://mariadb.com/kb/en/constraint/

like image 184
Abit Gray Avatar answered Sep 27 '22 16:09

Abit Gray