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 3 years have passed since last update.

HeidiSQL上でMariaDBのデータベースをそのままエクスポート&インポートしたらエラーになっちゃたよぉ~の原因と対応

Last updated at Posted at 2020-11-10

バージョン

Windows10 Pro バージョン1909 OSビルド18363.1171
MariaDB 10.5.4
HeidiSQL 11.0.0.5919

どんな時起こったん?

HeidiSQL上でデータベースをそのままSQLとしてエクスポート。
image.png

そのSQLをそのまま実行すればデータベースがまるっと復元されると思ったけどエラー。
SQLエラー(1064): You have an error in your SQL syntax; check the manual than corresponds to your MariaDB server version for the right syntax to use near …
image.png

原因

データベース内に存在しないテーブルを参照しているビューがあった。
テーブル名を変更したのにそのテーブルを参照しているビューを変更し忘れた、ってそれだけのこと…。

対応

HeidiSQL上でビューを修正すればOK。
修正前に下図のエラー出るけど無視してSQL直して保存でOK。
image.png

蛇足

HeidiSQLはviewを変更しようとした時は整合性チェックするけど、テーブルを変更した時はビューの整合性をチェックしてくれません。
まあ、使う側が影響範囲確認しようねって話ではあるんだけど…、チェックしてくれるとありがたいなあ…。

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?