Skip to content

Instantly share code, notes, and snippets.

@gobinathm
Created June 13, 2019 16:58
Show Gist options
  • Save gobinathm/32df7d762eb41b7c9ab0813a5db26f53 to your computer and use it in GitHub Desktop.
Save gobinathm/32df7d762eb41b7c9ab0813a5db26f53 to your computer and use it in GitHub Desktop.
Search Entire DB & Delete records on specific text
SELECT
CONCAT('delete FROM ', A.TABLE_SCHEMA, '.', A.TABLE_NAME,
' WHERE ', A.COLUMN_NAME, ' LIKE \'%fr%\';')
FROM INFORMATION_SCHEMA.COLUMNS A
WHERE
A.TABLE_SCHEMA != 'mysql'
AND A.TABLE_SCHEMA != 'innodb'
AND A.TABLE_SCHEMA != 'performance_schema'
AND A.TABLE_SCHEMA != 'information_schema'
AND (
A.DATA_TYPE LIKE '%text%'
OR
A.DATA_TYPE LIKE '%char%'
)
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment