开发者

MySQL Search Within Database (Table Search)

Alright, I'm trying to write a query to display all the tables that contain a cer开发者_运维问答tain prefix. Something like what is displayed below (but is obviously incorrect)

SELECT TABLES LIKE chat_

So any table that has the chat prefix, would be displayed. I plan on formatting the output, so it's not going to be a raw output, and I also understand that "what idiot would display table names publicly", and security measures are being taken to prevent that "accidental" table drop (just trying to avoid a flame war). So, how is this accomplished?


You can also use regular expressions, which allows a little more flexibility (though a performance cost):

SHOW TABLES WHERE tables_in_db REGEXP 'chat.*';

In this example, replace db with the database name of concern.


SHOW TABLES LIKE 'chat_%';


You need to add "in some_db first" before where like below

 SHOW TABLES in test_server_service where 'table' regexp 't_*';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜