DBAtlas · データベース運用アトラス

互換性レベル/機能バージョンを設定

Oracle

-- Raise the COMPATIBLE initialization parameter (irreversible!):
ALTER SYSTEM SET COMPATIBLE = '19.0.0' SCOPE=SPFILE;
-- Then restart the instance. To see the current value:
SHOW PARAMETER compatible;

COMPATIBLE パラメータは、どのバージョンの機能とファイル形式を有効にするかを決める。一度引き上げてインスタンスを再起動すると元に戻せない(ダウングレードはブロックされる)。そのため、アップグレードの成功が確認されるまで段階的に引き上げる。

PostgreSQL

# Not applicable: PostgreSQL has no database compatibility level.
# If legacy behavior is needed, set the relevant GUCs (e.g. SET standard_conforming_strings=off)
# or manage the major migration with dump/restore.

PostgreSQL には SQL Server/Oracle のような「互換性レベル」の概念はなく、バージョンの挙動はバイナリバージョンに直接結び付く。バージョン間の移行は pg_dump/pg_restore または pg_upgrade で行う。

MySQL

# Not applicable: MySQL has no configurable database compatibility level.
# Behavioral differences are managed with sql_mode:
SET GLOBAL sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION';

MySQL にはバージョンベースの互換性レベルはなく、SQL の挙動は主にバイナリバージョンと sql_mode の設定に依存する。既存アプリケーションの挙動を維持するには sql_mode を細かく調整する。

SQL Server

-- Set the database compatibility level (e.g. SQL Server 2022 = 160):
ALTER DATABASE Sales SET COMPATIBILITY_LEVEL = 160;
-- To see the current value:
SELECT name, compatibility_level FROM sys.databases;

COMPATIBILITY_LEVEL は、クエリオプティマイザと言語機能がどのバージョンのように動作するかを決める(150=2019、160=2022)。インスタンスのアップグレード後もデータベースは旧レベルのままにでき、段階的に引き上げて実行計画の劣化を監視することが推奨される。再度下げることもできる。

MongoDB

// Set the Feature Compatibility Version (FCV):
db.adminCommand({ setFeatureCompatibilityVersion: "7.0", confirm: true })
// Read the current value:
db.adminCommand({ getParameter: 1, featureCompatibilityVersion: 1 })

FCV は、バージョンに伴う永続データ形式の変更と新機能をいつ有効にするかを制御する。バイナリのアップグレード後、クラスタが安定している間に引き上げる。引き下げは、同じバイナリバージョンが下位の FCV をまだサポートしている場合のみ可能。

Redis

# Not applicable: Redis has no compatibility level / feature version concept.
# Behavior depends directly on the running binary version.

Redis には設定可能な互換性レベルがなく、機能セットは実行中のバージョンに完全に依存する。互換性は RDB/AOF のファイル形式レベルで、前方向にのみ維持される。

Elasticsearch

# Not applicable: Elasticsearch has no configurable compatibility level.
# An index is tied to the format of the version it was created in; very old indices
# cannot be read in the new version and require a reindex.

Elasticsearch には互換性レベルの設定がなく、各インデックスは作成されたメジャーバージョンの形式を保持する。前のメジャーバージョンで作成されたインデックスは読めるが、それより古いものは _reindex で新バージョンに移行する必要がある。

DBAtlas で開く →