Skip to content

Instantly share code, notes, and snippets.

@aa21
Last active August 29, 2015 14:10
Show Gist options
  • Save aa21/50425fd7423c385f5a02 to your computer and use it in GitHub Desktop.
Save aa21/50425fd7423c385f5a02 to your computer and use it in GitHub Desktop.
Bruteforce. Index all the columns in all tables of a db.
-- Bruteforce. Index all the columns in all tables of a db.
-- Find the data types
-- select distinct data_type from information_schema.columns where table_schema="DATABASE";
select
concat( "ALTER TABLE `DATABASE`.`", table_name , "` ADD INDEX ( `",column_name ,"` );" )
from information_schema.columns where table_schema='DATABASE' and
data_type not in ('text', 'longtext', 'mediumtext','tinytext' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment