Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Only show tables with certain patterns in mysql "show tables"

There are too many tables in a db. how can I only show tables with certain patterns? Or is there a way I can do paging like "| more" in shell command?

like image 901
user398384 Avatar asked Aug 04 '10 16:08

user398384


People also ask

How do I find which tables have a particular column in MySQL?

How to list all tables that contain a specific column name in MySQL? You want to look for tables using the name of columns in them. SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA. COLUMNS WHERE COLUMN_NAME IN('column1', 'column2') AND TABLE_SCHEMA = 'schema_name';

How do I get a list of tables in MySQL?

To get a list of the tables in a MySQL database, use the mysql client tool to connect to the MySQL server and run the SHOW TABLES command. The optional FULL modifier will show the table type as a second output column.


2 Answers

show tables like 'pattern'; 
like image 141
a'r Avatar answered Sep 21 '22 05:09

a'r


  • use show tables like 'pattern'
  • pattern is a string using wildcard characters "%","_"
  • % matches any number of characters, even zero characters.
  • _ matches exactly one character.

for example:

  • show tables like 'test%' will filter tables such as "test1,testF,test111,testFoo"

  • show tables like 'test_' will filter tables such as "test1,testF"

like image 29
wengeezhang Avatar answered Sep 20 '22 05:09

wengeezhang