mysql查询一个列名都存在于哪些表

select  table_name  from  information_schema.columns  where  column_name='id';

information_schema类似一个database,showdatabases可以查到,通过use information_schema、show tables观察其中的表, columns为其中一个表,show create table columns\G;

观察其内容,table_name、column_name即为其中两个列,语句意思就是 从表columns中找到所有存在id这一列的表的名字。

Copyright © 2015-2026