I'm looking for a database engine that can handle data constraints specified via RegEx. So in addition to the datatype, I want to be able to control the format of the data. E.g. a varchar(255)
field could be further restrained to be like [a-zA-Z0-9 ]
.
I need the RegEx to be able to be queried too, so I can share those constraints throughout the n-tier system to enforce on several levels. E.g. MySQL allows for querying of information_schema
to get meta data, and other database engines have similar ways.
I did a post yesterday (MySQL Queriable Field Constraint by RegEx), referencing things I read, but doesn't look promising with MySQL, so I'm opening this up to any db engine, although I would prefer MS SQL, Oracle, DB2 or MySQL, as it'll be easier to sell the business on.
Is there a database engine out there that allows for these regex restrictions? If so, which one is it and how do the constraints get set and queried?
In Oracle you can specify custom constraints, in which you can use functions that evaluate regexp; for example:
You can get informations on constraints you set with something like:
Here is a wildcard example in sql server for this.
If you want to use some t-sql to view the definitions of your check constraints you can use the sys.check_constraints catalog view.
Here is an example to view ALL the check constraints for the table above. The definition columns will provide the wildcard searching as defined in the constraint.