2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MySQL カラム名を小文字に変換したい

Last updated at Posted at 2015-06-04

カラム名に、大文字・小文字が混ざっていてWindowsやMacからLinuxにデータを移行したら動かないなんてことになったときのためのメモ

素直に小文字に統一しようぜとなった場合

カラム名を変更するSQL(itemテーブルのIDをidに変換する)
alter table item change ID id varchar(12);

上記のSQLを一括で作成するSQL
select concat('alter table ',table_name,' change ',column_name,' ',LOWER(column_name),' ',column_type, ';' ) from INFORMATION_SCHEMA.COLUMNS where TABLE_SCHEMA = 'データベース名(スキーマー)'

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?