mysql依據某一張表的字段,查詢出對應的表所在的數據庫


表太多,只記得這個表有一個mygame的字段,但是並不知道這張表在那個數據庫下,只能根據這個字段查找對應的表和所在數據庫

select table_schema,table_name from information_schema.columns where column_name = '字段名'

演例:

mysql> select table_schema,table_name from information_schema.columns where column_name = 'gname';

查詢結果:
+--------------+-------------------+
| table_schema | table_name        |
+--------------+-------------------+
| ccc          | mygame            | # 可知道在ccc這個數據庫下
| student      | app01_class_grade |
+--------------+-------------------+
2 rows in set (0.36 sec)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM