🐷

DBマイグレーションでありますまいか [revision.4]

2021/01/12に公開

関数とうまく付き合おう - マイグレーションにやさしい「データベースとのかかわり方」 という名でQiitaに再編集しましたぞ。

以下はその元となるネタ集めの過程のもの。

スムーズなDBマイグレーションのためには
最初から移行しやすい形に作っておくという長期的戦略
とにかく移行するという短期的戦略 2つがある。

Sqlスタイルガイド

最初から移行しやすい形に作っておくことの1つ目。

SQLスタイルガイド
2015年の記事

「分析SQLスタイルガイド」をかなり真面目に考えた
2021年の最新記事

SQLStyleGuide

オンラインフォーマッタ

http://poorsql.com/
https://sql-formatter.online/options/formatting

Two free tools to format SQL queries

SQLアンチパターン

https://qiita.com/iwata@github/items/9a47ddababd8e0a82662

https://alek3.hatenablog.com/entry/2017/10/28/230220

https://www.slideshare.net/t_wada/sql-antipatterns-digest

本当に合ったやらかしDB設計シリーズ

本当にあったやらかしDB設計シリーズ一覧
本当にあったやらかしDB設計①【R無しRDB】
本当にあったやらかしDB設計②【囚人番号テーブル】
本当にあったやらかしDB設計③【ロジカルクエリー】
本当にあったやらかしDB設計④【テストチューニング】
本当にあったやらかしDB設計⑤【第三正規化病】
本当にあったやらかしDB設計⑥【見えない削除フラグ】
[本当にあったやらかしDB設計⑦【ステートフルDB】]
(https://qiita.com/bouitengineer12/items/325fec42c1c3bb385c64)
本当にあったやらかしDB設計⑧【ファンクションDB】
本当にあったやらかしDB設計⑨【文字列日付】

番外編
T字形ER手法って何???
インピーダンスミスマッチとどう向き合うか
どこまでデータを消すのか

DBマイグレーション

Sqlines
DBマイグレーションに強力なサイトのようだ

http://www.sqlines.com/oracle-to-postgresql
等。

To_date

主にPostgres

PostgreSQL is the DBMS of the Year 2020

How much will it cost to migrate from Oracle DB with 500 tables, which also has triggers and functions, to an open-source DB, for example PostgreSQL? The application itself has around 300.000 lines of code.

OracleからPostgreSQL移行について

Why use Oracle instead of Postgres?

https://db-engines.com/en/system/Oracle%3BPostgreSQL

  1. Features
  2. The cost of open source
    Proponents of open source software, myself included, tend to ignore the cost of open source.
    Even “free as in beer” code needs work in order to understand how to install, use and integrate it.
    If it breaks down, it is harder to find an expert to help you, even with the wonderful developer communities and StackOverflow.
    While the cost of commercial systems is explicit, the implicit cost of open source might be non-negligible.
  3. Vested interest - Suppose you are building a new database at a site of a hundred-branch enterprise,
    which already uses Oracle. You would need a good reason not to go with Oracle,
    because it is easier to maintain a known system, and your company probably has qualified staff and procedures for working with Oracle.
  4. Integration - Similarly, If you want to integrate your database with an existing code base, which is better suited to work with Oracle, this also points in the way of Oracle.
  5. Regulation/Company Culture - Some industries and companies want a known

Why are more companies switching to Postgres?

MySQL Vs Amazon Aurora: Is Aurora a Game-changer in Database Market?

以下は、ごった煮

https://ja.wikipedia.org/wiki/SQL

TruncateVsDelete
WHERE句がつけられるか
IDを含め消えるか
TRIGGERが効くか効かないか

DELETE文とTRUNCATE文の違い
削除対象を選べるかどうか
ロールバックできるかどうか
処理時間が速いかどうか

DELETEとTRUNCATEの違い
HWMをリセットするかしないか

SQL文 DELETE・TRUNCATE・DROPの違い

Oracleでは外部結合の(+)が非推奨なので勉強してみた
Oracle19cにおけるTO_DATE関数の挙動
TO_CHARにTO_DATEを重ねる意味
ぐるぐるSQL
ユーザー定義関数と「ひとつの SQL」ではパフォーマンスが数百% も違う!?
動的なSQLクエリの生成でちょっとトリッキーな構築方法

w3schools
https://www.w3schools.com/sql/default.asp

他、むかしOracle/DB2 対応時に書き換えになった項目

  • TO_CHAR, TO_DATE
  • TRUNCATE
  • 空文字列と Null の違い
  • to_date + 1 のような
  • ROWID, ROWNUM

Discussion