HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMajor

How to search for a specific column name in all the tables in MySQL Workbench?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
tablesthehowsearchcolumnallworkbenchmysqlnamefor

Problem

In MySQL Workbench, is it possible to search for a specific column name in all the tables?

(Writing the string to look for in the field at the top right does nothing).

Thank you.

Solution

You can use the INFORMATION_SCHEMA database and the COLUMNS table in particular Example of use:

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%'

Code Snippets

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%'

Context

StackExchange Database Administrators Q#33333, answer score: 35

Revisions (0)

No revisions yet.