Search code examples
mysqlregexrlike

Select MySQL tables ending in _timestamp with matching regxp


I'm trying to isolate some tables in a mysql database that match a pattern which can be described as

some-name_10-digit timestamp

eg:

| oxseohistory_1381393508       |
| oxseohistory_1382427650       |
| oxseohistory_1382617597       |

Is there a way to use a regular expression which matches everything with 10 digits at the end? Like this one?

\d{10}$

I tried

 SHOW TABLES FROM `usrdb_xxxx` WHERE `Tables_in_usrdb_xxxx` RLIKE '\d{10}$';

which did not work (empty set).


Solution

  • As MySQL does not support \d, you can use

    [[:digit:]]{10}$
    

    Or

    [0-9]{10}$