How to Rename Column in all tables in MySQL Database - MySQL Developer Tutorial

How to Rename Column in all tables in MySQL Database

Let's say you have a column that is part of all the tables and you need to generate script to rename as MySQL Developer. 

You can use below script to generate script to Rename a Column from all the tables in MySQL Database. 
In below example, I am renaming "CreateDT" column to "CreateDate" for all the tables in "TechBrothers" database. You can make changes as per your requirement to @DatabaseName and @ColumnName.



SET @DatabaseName ="TechBrothers";
SET @ColumnName= " Rename Column CreateDT to CreateDate";
SELECT Concat('ALTER TABLE  ', TABLE_NAME,@ColumnName,';') as Query
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = @DatabaseName;



Rename Column in all tables in MySQL Database - MySQL Developer Tutorial for Beginners