kfirba
kfirba

Reputation: 5441

get all tables names that start with a string

I've lot of tables in my database and I wanted to know if there is any way I can get all the tables names that start with a certain string.

For example, I have this string: my_table and I would like to get all of the tables names that starts with it. The expected result would be my_table_* so it's pretty much everything that starts with it.

Is it possible?

Thanks in advance!

Upvotes: 0

Views: 2555

Answers (2)

karlbarbour
karlbarbour

Reputation: 352

SELECT table_name 
  FROM information_schema.tables 
 WHERE table_name LIKE 'string_here%';

Should do the trick

Upvotes: 4

Aman Aggarwal
Aman Aggarwal

Reputation: 18459

Simple command:

SHOW TABLES LIKE 'my_table*'

Thanks

Upvotes: 1

Related Questions