LoginSignup
44
36

More than 5 years have passed since last update.

MySQLでカラムの順番を変更する

Posted at

よく忘れるので、メモ

以下のようなテーブルがあったとします。

id
title
description
user_id

以上を以下のようにしたい

id
user_id
title
description

alter table テーブル名 modify 移動したいカラム名 text after 移動したいカラム名の上にくるカラム名;例えば以上のようにuser_ididの下に持ってきたい場合。
alter table テーブル名 modify user_id text after id;とする

44
36
1

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
44
36