diff --git a/README.md b/README.md index 806e3cb29963a67914f9354f7cece260b85f791a..14fe5c847f79f6963d6ae06fcec65b2067266d0b 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,23 @@ openGauss-tools-sql-translator是一个使用java编写的实现MySQL向openGaus ## MySQL与openGauss的兼容性说明 -根据SQL语句在MySQL5.7官方文档和openGauss 3.0.0官方文档的差异对比,对各SQL语句进行翻译。 +根据SQL语句在MySQL5.7官方文档和openGauss 3.0.0官方文档的差异对比,对各SQL语句进行翻译。下表展示SQL语句的翻译情况。 + +| SQL语句 | 翻译情况 | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- | +| [ALTER EVENT Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-event.html)、[ALTER INSTANCE Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-instance.html)、[ALTER LOGFILE GROUP Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-logfile-group.html)、[ALTER PROCEDURE Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-procedure.html)、[CREATE EVENT Statement](https://dev.mysql.com/doc/refman/5.7/en/create-event.html)、[CREATE LOGFILE GROUP Statement](https://dev.mysql.com/doc/refman/5.7/en/create-logfile-group.html)、[DROP EVENT Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-event.html)、[DROP LOGFILE GROUP Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-logfile-group.html)、[DO Statement](https://dev.mysql.com/doc/refman/5.7/en/do.html)、[HANDLER Statement](https://dev.mysql.com/doc/refman/5.7/en/handler.html)、[REPLACE Statement](https://dev.mysql.com/doc/refman/5.7/en/replace.html)、[Replication Statements](https://dev.mysql.com/doc/refman/5.7/en/sql-replication-statements.html)、[ITERATE Statement](https://dev.mysql.com/doc/refman/5.7/en/iterate.html)、[Condition Handling](https://dev.mysql.com/doc/refman/5.7/en/condition-handling.html)、[SET PASSWORD Statement](https://dev.mysql.com/doc/refman/5.7/en/set-password.html)、[CHECK TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/check-table.html)、[CHECKSUM TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/checksum-table.html)、[OPTIMIZE TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/optimize-table.html)、[REPAIR TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/repair-table.html)、[Plugin and Loadable Function Statements](https://dev.mysql.com/doc/refman/5.7/en/component-statements.html)、[SET NAMES Statement](https://dev.mysql.com/doc/refman/5.7/en/set-names.html)、[SET CHARACTER Statement](https://dev.mysql.com/doc/refman/5.7/en/set-character-set.html)、[SHOW Statements](https://dev.mysql.com/doc/refman/5.7/en/show.html)、[BINLOG Statement](https://dev.mysql.com/doc/refman/5.7/en/binlog.html)、[CACHE INDEX Statement](https://dev.mysql.com/doc/refman/5.7/en/cache-index.html)、[FLUSH Statement](https://dev.mysql.com/doc/refman/5.7/en/flush.html)、[KILL Statement](https://dev.mysql.com/doc/refman/5.7/en/kill.html)、[LOAD INDEX INTO CACHE Statement](https://dev.mysql.com/doc/refman/5.7/en/load-index.html)、[DESCRIBE Statement](https://dev.mysql.com/doc/refman/5.7/en/describe.html)、[HELP Statement](https://dev.mysql.com/doc/refman/5.7/en/help.html) | openGauss不支持 | +| [SHUTDOWN Statement](https://dev.mysql.com/doc/refman/5.7/en/shutdown.html) | Druid不支持 | +| [ALTER DATABASE Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-database.html)、[ALTER FUNCTION Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-function.html)、[ALTER SERVER Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-server.html)、[ALTER TABLESPACE Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-tablespace.html)、[CREATE SERVER Statement](https://dev.mysql.com/doc/refman/5.7/en/create-server.html)、[CREATE TABLESPACE Statement](https://dev.mysql.com/doc/refman/5.7/en/create-tablespace.html)、[DROP TRIGGER Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-trigger.html)、[Prepared Statements](https://dev.mysql.com/doc/refman/5.7/en/sql-prepared-statements.html)、[Cursors](https://dev.mysql.com/doc/refman/5.7/en/cursors.html)、[ANALYZE TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/analyze-table.html)、[RESET Statement](https://dev.mysql.com/doc/refman/5.7/en/reset.html)、[EXPLAIN Statement](https://dev.mysql.com/doc/refman/5.7/en/explain.html) | 无法兼容 | +| [ALTER TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-table.html)、[ALTER VIEW Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-view.html)、[CREATE DATABASE Statement](https://dev.mysql.com/doc/refman/5.7/en/create-database.html)、[CREATE FUNCTION Statement](https://dev.mysql.com/doc/refman/5.7/en/create-function.html)、[CREATE INDEX Statement](https://dev.mysql.com/doc/refman/5.7/en/create-index.html)、[CREATE PROCEDURE Statements](https://dev.mysql.com/doc/refman/5.7/en/create-procedure.html)、[CREATE TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/create-table.html)、[CREATE TRIGGER Statement](https://dev.mysql.com/doc/refman/5.7/en/create-trigger.html)、[CREATE VIEW Statement](https://dev.mysql.com/doc/refman/5.7/en/create-view.html)、[DROP DATABASE Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-database.html)、[DROP INDEX Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-index.html)、[DROP TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-table.html)、[DROP TABLESPACE Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-tablespace.html)、[DELETE Statement](https://dev.mysql.com/doc/refman/5.7/en/delete.html)、[INSERT Statement](https://dev.mysql.com/doc/refman/5.7/en/insert.html)、[SELECT Statement](https://dev.mysql.com/doc/refman/5.7/en/select.html)、[Subqueries](https://dev.mysql.com/doc/refman/5.7/en/subqueries.html)、[UPDATE Statement](https://dev.mysql.com/doc/refman/5.7/en/update.html)、[START TRANSACTION, COMMIT, and ROLLBACK Statements](https://dev.mysql.com/doc/refman/5.7/en/commit.html)、[SET TRANSACTION Statement](https://dev.mysql.com/doc/refman/5.7/en/set-transaction.html)、[ALTER USER Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-user.html)、[CREATE USER Statement](https://dev.mysql.com/doc/refman/5.7/en/create-user.html)、[RENAME USER Statement](https://dev.mysql.com/doc/refman/5.7/en/rename-user.html)、[GRANT Statement](https://dev.mysql.com/doc/refman/5.7/en/grant.html)、[REVOKE Statement](https://dev.mysql.com/doc/refman/5.7/en/revoke.html)、[SET param_name](https://dev.mysql.com/doc/refman/5.7/en/set-variable.html)、[USE Statement](https://dev.mysql.com/doc/refman/5.7/en/use.html) | 部分支持 | +| [DROP FUNCTION Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-function.html)、[DROP PROCEDURE](https://dev.mysql.com/doc/refman/5.7/en/drop-procedure.html)[and DROP FUNCTION Statements](https://dev.mysql.com/doc/refman/5.7/en/drop-procedure.html)、[DROP SERVER Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-server.html)、[DROP VIEW Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-view.html)、[RENAME TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/rename-table.html)、[TRUNCATE TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/truncate-table.html)、[CALL Statement](https://dev.mysql.com/doc/refman/5.7/en/call.html)、[BEGIN ... END Compound Statement](https://dev.mysql.com/doc/refman/5.7/en/begin-end.html)、[Statement Labels](https://dev.mysql.com/doc/refman/5.7/en/statement-labels.html)、[DECLARE Statement](https://dev.mysql.com/doc/refman/5.7/en/declare.html)、[CASE Statement](https://dev.mysql.com/doc/refman/5.7/en/case.html)、[IF Statement](https://dev.mysql.com/doc/refman/5.7/en/if.html)、[LEAVE Statement](https://dev.mysql.com/doc/refman/5.7/en/leave.html)、[LOOP Statement](https://dev.mysql.com/doc/refman/5.7/en/loop.html)、[REPEAT Statement](https://dev.mysql.com/doc/refman/5.7/en/repeat.html)、[RETURN Statement](https://dev.mysql.com/doc/refman/5.7/en/return.html)、[WHILE Statement](https://dev.mysql.com/doc/refman/5.7/en/while.html)、[DROP USER Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-user.html) | 完全支持 | + +* openGauss不支持,表明会在日志中输出ERROR,由于该语句存在于需迁移的数据库对象中,所以该数据库对象迁移失败; +* Druid不支持,表明该语句解析不成功,拥有该语句的数据库对象也迁移失败; +* 无法兼容,表明openGauss与MySQL一样支持该语句,但由于某些字段差异导致openGauss和MySQL之间无法转换。 +* 完全支持指该语句的所有字段都可转化成openGauss的相应字段。 +* 部分支持表明已尽可能地进行转换。若存在某些字段无法兼容但不影响整条语句的使用,则将该关键字进行注释处理;若某字段无法兼容且影响该语句的使用,则在日志中输出ERROR,说明该语句不能兼容的原因,拥有该语句的数据库对象迁移失败。比如在openGauss中[CREATE TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/create-table.html)的AS query_expression不兼容MySQL;在openGauss中[DELETE Statement](https://dev.mysql.com/doc/refman/5.7/en/delete.html)不支持多表删除语法;在openGauss中[SELECT Statement](https://dev.mysql.com/doc/refman/5.7/en/select.html)的select into字段仅支持变量是存储过程和函数参数或局部变量;在openGauss中[UPDATE Statement](https://dev.mysql.com/doc/refman/5.7/en/update.html)不支持同时更新多表;GRANT statement、REVOKE statement语句若出现openGauss不支持赋予的privilege也会导致该语句无法迁移的情况;与PARTITION分区相关的语句也有可能因某些字段导致迁移失败等等,具体原因请查看日志。 + +以下对MySQL5.7版本的所有SQL语句具体的翻译情况进行说明。 ### [13.1.1 ALTER DATABASE Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-database.html) @@ -254,6 +270,7 @@ openGauss-tools-sql-translator是一个使用java编写的实现MySQL向openGaus > 1. 在STRAT TRANSACTION语句中,openGuass不支持WITH CONSISTENT SNAPSHOT字段 > 2. 在BEGIN、COMMIT、ROLLBACK语句中,openGauss不支持AND [NO] CHAIN 、[NO] RELEASE字段 > 3. 在SET TRANSACTION语句中,openGuass不支持GLOBAL、READ UNCOMMITTED字段。MySQL字段SESSION在openGauss中翻译为SESSION CHARACTERISTICS AS +> 4. 目前的sql-translator不支持在对象中使用(如存储过程)COMMIT、ROLLBACK语句,解析出错 ### [13.4 Replication Statements](https://dev.mysql.com/doc/refman/5.7/en/sql-replication-statements.html)