LoginSignup
1
0

More than 5 years have passed since last update.

既存のテーブルにカラムを追加 - Laravel/MySQL/Postgresなど

Posted at

追加方法

Laravel

Schema::table('users', function (Blueprint $table) {
    $table->string('email');
});

Postgres

ALTER TABLE users ADD email int;

追加位置を指定する

MySQL

コマンドでできる
https://www.dbonline.jp/mysql/table/index20.html

Postgres

コマンドではできない。
頑張ったらできないこともないらしいが大変そう。
http://kashi.way-nifty.com/jalan/2014/11/post-cbf4.html

カラムを削除する

Laravel

https://laravel.com/docs/5.4/migrations#columns のDropのところ

Schema::table('user', function (Blueprint $table) {
    $table->dropColumn('email');
});

1
0
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
1
0