I am trying to write a stored procedure in MariaDB/MySQL that will return table names, if any, within the schema that matches a pattern provided by the parameters. Guessing this is accomplished by querying the information_schema table, but any advice and example would be appreciated.
2
Answers
You can use simple select like this:
Here we select all tables from schema
mysql
that containm
in the name.Surprisingly, you can access this information even on demo sites. Here is demo at dbfiddle.
This query does what you want, if by pattern-matching you mean SQL’s LIKE-style matching.
Pretty straightforward. You could put this into a stored procedure. Or not. Depending on the complexity of software deployment you’re looking for.