Skip to main content

Generate SQL to replace 'old_text' with 'new_text' in all character columns in 'dbname'.

Select Concat( 'update ', table_schema, '.', table_name,
               ' set ', column_name,
               '=replace(', column_name, ',''old_text'',''new_text'');'
             )
From information_schema.columns
Where (data_type Like '%char%' or data_type like '%text' or data_type like '%binary')
  And table_schema = 'dbname';