diff --git a/product/en/docs-mtk/v2.0/faq/mtk-mysql-to-openGauss.md b/product/en/docs-mtk/v2.0/faq/mtk-mysql-to-openGauss.md index 88f1e231ae1f37b8518327e7fd860b6455a8798c..ce02140ee5f0e609ebfc61eeb5980e37bc9abf32 100644 --- a/product/en/docs-mtk/v2.0/faq/mtk-mysql-to-openGauss.md +++ b/product/en/docs-mtk/v2.0/faq/mtk-mysql-to-openGauss.md @@ -75,6 +75,39 @@ select schema_name,default_character_set_name,DEFAULT_COLLATION_NAME from inform > MTK does not migrate the COLLATE attribute for the time being. Manual intervention is required to confirm and create the schema. > Whether migration will be considered in later versions is to be determined. +### Sequence/Auto_increment + +MySQL does not have sequences. Migrate to target-side sequences when column attribute `auto_increment` is not supported. + +- Auto_increment is not supported + + - Compatibility mode is not B mode. + - Compatibility mode B mode does not install plugin `dolphin` + - Compatibility mode B mode and plugin `dolphin` is installed, database version is less than 3.1.0 + + ```sql + - Create sequence + create sequence sequence_name; + - Specify column default value as sequence next + create table table(col col_type default nextval('sequence_name')); + - Modify sequence owner + alter sequence sequence_name owned owner.table_name.column_name + - Modify sequence last value + select setval('',last_number); + ``` + +- Auto_increment is supported + + Compatibility mode B mode and plugin `dolphin` is installed, database version is greater than 3.1.0 + + ```sql + - Do not create sequence + - Specify column attribute auto_increment + create table table(col col_type auto_increment); + --Modify the last value of the sequence + alter table owner.table_name auto_increment=last_number + ``` + ### Table - rewrite the `auto-increment` column as the default sequence diff --git a/product/zh/docs-mtk/v2.0/faq/mtk-mysql-to-openGauss.md b/product/zh/docs-mtk/v2.0/faq/mtk-mysql-to-openGauss.md index 23cc10a27d459a330302f6fc940df82a5e0ad886..53cb8ee56ae09fc2205d2d19bcd02bd2d6fb8ece 100644 --- a/product/zh/docs-mtk/v2.0/faq/mtk-mysql-to-openGauss.md +++ b/product/zh/docs-mtk/v2.0/faq/mtk-mysql-to-openGauss.md @@ -65,6 +65,39 @@ select schema_name,default_character_set_name,DEFAULT_COLLATION_NAME from inform > MTK 暂时不迁移COLLATE属性,需要人工介入确定好,创建schema > 后面版本会不会考虑迁移待定 +### 序列/自增列 + +MySQL 没有序列. 在不支持列属性 `auto_increment` 的情况下迁移为目标端序列. + +- 不支持 auto_increment + + - 兼容模式非B模式. + - 兼容模式B模式未安装插件`dolphin` + - 兼容模式B模式并且安装插件`dolphin`,数据库版本小于于3.1.0 + + ```sql + -- 创建序列 + create sequence sequence_name; + -- 指定列默认值为序列next + create table table(col col_type default nextval('sequence_name')); + -- 修改序列所属者 + alter sequence sequence_name owned owner.table_name.column_name + -- 修改序列最后值 + select setval('',last_number); + ``` + +- 支持 auto_increment + + 兼容模式B模式并且安装插件`dolphin`,数据库版本大于3.1.0 + + ```sql + -- 不创建序列 + -- 指定列属性 auto_increment + create table table(col col_type auto_increment); + -- 修改序列最后值 + alter table owner.table_name auto_increment=last_number + ``` + ### 表 - 自增列改写为默认值序列