兼容性判定
公开资料依据 · 建议 PoC 复核支持度partial
严重度critical
置信度low
依据规则my.ddl.check_constraint
怎么改
清洗存量数据后显式 ADD CONSTRAINT,并确认目标约束功能开关
判定说明
PostgreSQL 原生执行 CHECK;仍建议 PoC 复核 NOT VALID、函数可变性与存量数据校验
库侧 / 应用侧路径
库侧改造
可行:分离新增列与约束 DDL,启用约束并验证存量数据
应用侧改造
可行:应用校验只能作为补充,不能替代并发写入下的数据库约束
推荐路线:db_side。验证建议:插入/更新违反值必须失败,且迁移前后存量违规数一致
规则样例
CREATE TABLE account (balance DECIMAL(12,2), CONSTRAINT ck_balance CHECK (balance >= 0))
ALTER TABLE account ADD COLUMN age INT CHECK (age >= 0)
CHECK TABLE account
参考来源
- https://www.postgresql.org/docs/16/ddl-constraints.html#DDL-CONSTRAINTS-CHECK-CONSTRAINTS
- https://www.postgresql.org/docs/16/datatype.html
- https://www.postgresql.org/docs/16/functions.html
- https://www.postgresql.org/docs/16/sql-commands.html
- https://dev.mysql.com/doc/refman/8.0/en/create-table-check-constraints.html
- https://docs.pingcap.com/tidb/stable/constraints/
- https://github.com/pingcap/tidb/issues/6765
相关改造点
- MYSQL → postgresql 16 全部改造点
- postgresql 16 兼容性总览
- MYSQL 迁移国产库总览
- ORACLE ADD_MONTHS 函数 迁移 postgresql 16 怎么改
- ORACLE ALTER SESSION SET 会话参数 迁移 postgresql 16 怎么改
- ORACLE ANYDATA 动态类型列 迁移 postgresql 16 怎么改
- ORACLE ASCIISTR Unicode 转义函数 迁移 postgresql 16 怎么改
- ORACLE 关联数组(INDEX BY 表) 迁移 postgresql 16 怎么改
- ORACLE AT TIME ZONE 时区表达式 迁移 postgresql 16 怎么改