How to check all tables containing specified fields in mysql

To find all tables that contain a specific field, you can use INFORMATION_SCHEMA.COLUMNStable. column_nameThe following is an example query to find all tables in MySQL that contain a field named :

SELECT table_schema, table_name
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE column_name = 'column_name';

Please 'column_name'replace with the actual column name you want to find.

This query will return all tables in the database that contain this field. If you only want to search a specific database, you need to add it to the WHERE clause table_schema = 'your_database_name'. For example:

SELECT table_schema, table_name
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE column_name = 'column_name'
AND table_schema = 'your_database_name'

Please replace 'your_database_name'and 'column_name'with your actual database name and column name.

Guess you like

Origin blog.csdn.net/jkzyx123/article/details/132635901