0
0

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 1 year has passed since last update.

[MySQL] 既存カラムのデフォルト値をNULLに変更する

Posted at

あるカラムのデフォルト値をNULLに変更したい。

既存テーブル名   : sample_table
既存カラム名       : hoge_column
フィールドの型    : varchar(10)
フィールドの属性 : DEFAULT NULL

ALTER TABLE sample_table MODIFY COLUMN hoge_column varchar(10) DEFAULT NULL;

今回は sample_table の hoge_column に、可変長文字列10文字の型かつデフォルト値NULLを設定した。

参考:
すでに作成してあるカラムにNULLを格納できないようにする
https://26gram.com/mysql-not-null

ALTER TABLE テーブル名 MODIFY COLUMN カラム名 データ型 NOT NULL;
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?