OceanBase 集群中 MySQL 租户和 Oracle 租户对 INT 类型的转换有些差异。
无论是 MySQL 租户,还是 Oracle 租户,在对数字类型与字符类型进行比较时,总是优先把字符类型转换为数字类型,而在具体的转换规则上,MySQL 租户与 Oracle 租户又有不同。
MySQL 租户在对字符类型进行转换时,会截断第一个非 INT 类型之前的值。
Oracle 租户对于无法转换为数字的字符,会直接报错。
MySQL 租户示例
```shell
obclient [ob_mysql]> create table t1(id int auto_increment primary key,name varchar(128));
Query OK, 0 rows affected (0.337 sec)
```
```shell
obclient [ob_mysql]> insert into t1 values (1,'1');
Query OK, 1 row affected (0.105 sec)
```
```shell
obclient [ob_mysql]> select * from t1 where id ='1';
+----+------+
| id | name |
+----+------+
| 1 | 1 |
+----+------+
1 row in set (0.045 sec)
```
```shell
obclient [ob_mysql]> select * from t1 where id ='1xxx';
+----+------+
| id | name |
+----+------+
| 1 | 1 |
+----+------+
1 row in set (0.001 sec)
```
```shell
obclient [ob_mysql]> select * from t1 where id ='x1xxx';
Empty set (0.019 sec)
```
Oracle 租户示例
```shell
obclient [SYS]> create table t1(id int primary key, name varchar(128));
Query OK, 0 rows affected (0.261 sec)
```
```shell
obclient [SYS]> insert into t1 values (1,'1');
Query OK, 1 row affected (0.045 sec)
```
```shell
obclient [SYS]> select * from t1 where id ='1';
+----+------+
| ID | NAME |
+----+------+
| 1 | 1 |
+----+------+
1 row in set (0.016 sec)
```
```shell
obclient [SYS]> select * from t1 where id ='1xxx';
ORA-01722: invalid number
```
适用版本
OceanBase 数据库 V2.x 和 V3.x 版本。