Search code examples
mysqlgrep

how do I grep through a mysql database?


Looking for a nifty helper function/method for grepping through all defined tables, columns, stored procedures, etc, for a MySql database.

I had something similar for SQL Server.


Solution

  • In the INFORMATION_SCHEMA database:

    select * from columns WHERE TABLE_NAME LIKE '%tablename%' AND COLUMN_NAME LIKE '%columnname%'
    

    More info here: http://dev.mysql.com/doc/refman/5.0/en/information-schema.html

    Ok, it doesn't completely answer your question but you should be able to put it together how you want from here.