Answers:
您可以特别使用INFORMATION_SCHEMA
数据库和COLUMNS
表的使用示例:
SELECT
table_name,
column_name,
data_type,
ordinal_position
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_schema = 'myDatabase' --- the database you want to search
AND column_name = 'name' ; --- or: column_name LIKE '%name%'
要扩展@ypercube的答案(他得到+1),如果您不知道表所在的数据库,请执行以下操作:
SELECT
table_schema,
table_name,
column_name,
data_type,
ordinal_position
FROM INFORMATION_SCHEMA.COLUMNS
WHERE column_name = 'name' ; --- or: column_name LIKE '%name%'