How to find all the tables in MySQL with specific column names in them?
I have 2-3 different column names that I want to look up in the entire DB and list out all tables which have those columns. Any easy script?
要获取数据库YourDatabase
中的列columnA
或ColumnB
所有表:
SELECT DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME IN ('columnA','ColumnB')
AND TABLE_SCHEMA='YourDatabase';
SELECT TABLE_NAME, COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME LIKE '%wild%';
更简单地在一行SQL中完成:
SELECT * FROM information_schema.columns WHERE column_name = 'column_name';
链接地址: http://www.djcxy.com/p/30514.html
上一篇: 插入MySQL表或更新(如果存在)