LoginSignup
18
15

More than 5 years have passed since last update.

SQLSTATE[23000]: Integrity constraint violation 1048

Posted at

エラー概要

Integrity constraint violation => 整合性規約違反

上記のような意味となるので基本的には定義には当てはめられない挙動を実行しようとした場合に起こるエラーと考えて良い。

MySQL B.3 サーバーのエラーコードおよびメッセージ においてエラーコード「1048」 で検索を行うと以下のような説明がある。

  • エラー: 1048 SQLSTATE: 23000 (ER_BAD_NULL_ERROR)

    メッセージ: カラム '%s' は null にできません

実際に起こるケース

DBのテーブル定義を変更した

  • auto_incrementだったカラムをauto_incrementを外したが、補完するコードを入れ忘れた(「1062 Duplicate entry '0' for key 'PRIMARY'」など)

単純に起こる回数が少なかったが、定義忘れ

18
15
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
18
15