MySQL-重命名所有表和列为小写? [英] Mysql - Rename all tables and columns to lower case?

查看:56
本文介绍了MySQL-重命名所有表和列为小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将数据库从Windows盒转移到了Linux盒.这些表混合在大小写名称之间.我需要一种将所有表和列重命名为小写的方法.有可能吗?

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 to lowercase. Is that possible?

我在这个SO答案中看到,对于表格来说,但未找到任何与列名有关的内容.

I see in this SO answer it's possible for tables, but have not found anything that deals with column names.

推荐答案

您可以尝试使用Information_Schema.Columns表做完全相同的事情

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

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

这篇关于MySQL-重命名所有表和列为小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆