如何在 MySQL 中查找具有特定列名的表?
mysqlmysqli database
要查找列名,请使用 information_schema.columns。以下是语法 −
select distinct table_name from information_schema.columns where column_name like '%yourSearchValue%' and table_schema=database();
让我们实现上述语法,以便在各种表中查找列名。在这里,我们只需要具有特定列名单词"Client"的表名 −
mysql> select distinct table_name from information_schema.columns where column_name like '%Client%' and table_schema=database();
将产生以下输出 −
+----------------+ | table_name | +----------------+ | demotable449 | | demotable450 | | demotable461 | | demotable517 | | demotable529 | | demotable534 | | demotable537 | | demotable543 | | demotable547 | +----------------+ 9 rows in set (1.19 sec)
现在,让我们检查任意一个表并查找带有"Client"的单词列名称 −