먼저 −
를 생성해 보겠습니다.mysql> create table DemoTable1 -> ( -> StudentFirstName varchar(20), -> StudentLastName varchar(20), -> StudentAge int, -> StudentCountryName varchar(20) -> ); Query OK, 0 rows affected (4.20 sec)
이제 MySQL에서 모든 열 이름을 소문자로 만들겠습니다. -
mysql> select concat('alter table ', table_name, ' change `', column_name, '` `', -> lower(column_name), '` ', column_type, ';') -> from information_schema.columns where table_schema = 'demo';
이것은 다음과 같은 출력을 생성합니다 -
+-----------------------------------------------------------------------------------------------------------------+ | 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)