Mysql - Rename all tables and columns to lower case?

后端 未结 5 1169
日久生厌
日久生厌 2020-12-30 08:04

I recently transferred a database from a windows box to a linux box. The tables are mixed between lower and upper case names. I need a way to rename all tables and columns t

5条回答
  •  一向
    一向 (楼主)
    2020-12-30 08:30

    You can try to do exact same thing with Information_Schema.Columns table

    EDIT: Something like

    SELECT CONCAT('ALTER TABLE ', TABLE_NAME, ' CHANGE `', COLUMN_NAME, '` `',
    LOWER(COLUMN_NAME), '` ', COLUMN_TYPE, ';')
    FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '{your schema name}'
    

提交回复
热议问题