首批通过分布式安全可靠测评,为关键业务系统打造
通过 OBClient 执行 set define off/on 报 SQL 语法错误的原因及解决方法
更新时间:2026-06-03 03:01
问题现象
使用 OBClient 客户端工具执行 SQL 语句或 source sql 文件时,遇到报错。

obclient [SYS]> set define off;
ORA-00900: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'off' at line 1
使用的 OBClient 版本为 obclient V2.2.1。
问题原因
从 OBClient V2.2.4 开始,兼容了 Oracle sqlplus set define on/off,同 Oracle sqlplus 一样默认为 set define on。 因此,如果使用的 OBClient 版本低于 OBClient V2.2.4,不支持通过 OBClient 去执行 OceanBase 数据库 Oracle 模式中的 set define on/off,会遇到报错的(OBClient V2.2.4 之前的版本不支持 set define on/off 命令,会直接发给 OBServer 去处理。但是 set define on/off 本身并不是一条合法的 SQL 语句,所以 OBServer 会直接报语法错误。从 OBClient V2.2.4 版本开始 OBClient 开始支持了,就实现了 Oracle sqlplus 工具类似的功能)。
注意
OBClient V2.2.4 版本起默认行为的变化:当 SQL 中含有 & 字符就会同 Oracle sqlplus 一样提示替换变量。可以同 Oracle sqlplus 脚本一样设置 set define off 来修改默认行为,以保持和 OBClient V2.2.3 及以下版本一样默认的行为。生产环境如有通过 OBClient 执行 SQL 脚本的且 SQL 中含有 & 的尤其要注意!
问题的风险及影响
通过低版本 OBClient 客户端工具执行 set define on/off; 报语法错误失败。
适用版本
OBClient V2.2.3 及更低的版本。
OceanBase 数据库 Oracle 租户所有版本。
解决方法
升级 OBClient 工具到 V2.2.4 或最新的版本。
规避方式
无。