在特定数据库中查找字段

moonjerx
2021-12-06 / 0 评论 / 67 阅读 / 正在检测是否收录...
在整个MySQL数据库中查找
select * from INFORMATION_SCHEMA.columns where COLUMN_NAME Like '%placement%';
在特定数据库中查找
SELECT DISTINCT TABLE_NAME  FROM INFORMATION_SCHEMA.COLUMNS  WHERE COLUMN_NAME IN ('ColumnA','ColumnB') AND TABLE_SCHEMA='DatabaseName';
SELECT DISTINCT TABLE_NAME  FROM INFORMATION_SCHEMA.COLUMNS  WHERE COLUMN_NAME LIKE '%ColumnA%' AND TABLE_SCHEMA='DatabaseName';
在特定数据库中查找包含A和B字段的表
SELECT DISTINCT *  FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME IN ('A') and  TABLE_NAME in
(SELECT DISTINCT TABLE_NAME  FROM INFORMATION_SCHEMA.COLUMNS  WHERE COLUMN_NAME IN ('B')  AND TABLE_SCHEMA='DatabaseName')
0

评论 (0)

取消

您的IP: