
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Make all column names lower case in MySQL with a single query
Let us first create a −
mysql> create table DemoTable1 -> ( -> StudentFirstName varchar(20), -> StudentLastName varchar(20), -> StudentAge int, -> StudentCountryName varchar(20) -> ); Query OK, 0 rows affected (4.20 sec)
Let us now make all column names lower case in MySQL −
mysql> select concat('alter table ', table_name, ' change `', column_name, '` `', -> lower(column_name), '` ', column_type, ';') -> from information_schema.columns where table_schema = 'demo';
This will produce the following output −
+-----------------------------------------------------------------------------------------------------------------+ | concat('alter table ', table_name, ' change `', column_name, '` `', lower(column_name), '` ', column_type, ';') | +-----------------------------------------------------------------------------------------------------------------+ | alter table demotable1 change `StudentFirstName` `studentfirstname` varchar(20); | | alter table demotable1 change `StudentLastName` `studentlastname` varchar(20); | | alter table demotable1 change `StudentAge` `studentage` int(11); | | alter table demotable1 change `StudentCountryName` `studentcountryname` varchar(20); | | alter table mytable change `MyEuroColumn` `myeurocolumn` varchar(5); | +-----------------------------------------------------------------------------------------------------------------+ 5 rows in set (0.00 sec)
- Related Articles
- Lower case column names with MySQL SELECT?
- Set 'alias' for all the column names in a single MySQL query
- MySQL Query to change lower case to upper case?
- How to set all values in a single column MySQL Query?
- Concatenate all the columns in a single new column with MySQL
- Rename all tables and columns to lower case in MySQL?
- Setting column values as column names in the MySQL query result?
- How do I insert multiple values in a column with a single MySQL query?
- PHP – Make a lower case string using mb_strtolower()
- MySQL query to make a date column NULL?
- MySQL query to combine two columns in a single column?
- How to change column names to capital letters from lower case or vice versa in R?
- How to increment all the rows of a particular column by 1 in a single MySQL query (ID column +1)?
- MySQL query to return all items in a single row
- MySQL concat() to create column names to be used in a query?

Advertisements