tags:

views:

1443

answers:

2

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.

+2  A: 

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.

sjbotha
+1  A: 

I had the same requirement today, so I wrote a small Perl script. Google for dbgrep.pl to find it (it doesn't let me post a link here).