如何查询所有具有特定列名的表?
为了编写 MySQL 查询以获取所有具有特定列名的表,我们可以使用 LIKE 运算符。通过以下示例可以理解:-
示例
以下是获取所有在其列名中包含“ID”的表的 MySQL 查询:-
mysql> Select Column_name as 'ColumnName',Table_name As 'Tablename' FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE '%ID%' ORDER BY Tablename LIMIT 10; +-------------+---------------+ | ColumnName | Tablename | +-------------+---------------+ | id | arena | | id | arena1 | | ID | cars | | ID | COLLATIONS | | ID | copy_cars | | COUNTRY_ID | countries | | REGION_ID | countries | | Customer_Id | customers | | Customer_Id | customer_view | | id | emp | +-------------+---------------+ 10 rows in set, 0 warnings (0.15 sec)
广告