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

1 comment:

  1. Government of the People’s Republic of Bangladesh, Directorate of Primary Education (DPE), is going to announce PSC Result 2022 in DPE Result student wide on 30th December 2022 for all divisional Grade 5 exam result with Ebtedayee Result 2022 for annual final terminal examinations, The Primary School Certificate Examination Result 2022 will be announced for both of General and Madhrsah students in division wise to all education board known as Prathomik Somaponi Result 2022.

    ReplyDelete