11g表名大小写 oracle,Oracle和Mysql对表名大小写敏感测试

最近工作中,因为产品本身是支持oracle\mysql\sqlserver三种数据库,其中使用oracle是需要兼容11g升级到19c。在这个验证过程中,注意到之前没想过的关于表名大小写敏感的细节。

在oracle中,hibernate给映射建立的表名是大写的。在mysql中,hibernate给映射建立的表名是小写的。

测试后的结论:

mysql表名大小写敏感;

oracle表名大小写不敏感,语句执行时会把语句里小写的表名转化成大写去匹配,但使用""符号括起来的形式时,直接匹配符号里的内容。如果建表使用小写,使用""符号括起来的形式去匹配,比如"abc"。

测试代码:

--oracle环境测试 version: 19c

--前提:建立ASD表(表名大写)

select * from ASD; --查询正确

select * from asd; --查询正确 执行时相当于这里的小写转化成大写去找表

select * from "ASD"; --查询正确

select * from "asd"; --查询错误 ORA-00942: 表或视图不存在

--前提: 建立wsx表(表名小写)

select * from "wsx"; --查询正确 ""是oracle内置标识表名列名的符号 执行时不转化大写,直接匹配表名

select * from wsx; --查询错误 ORA-00942: 表或视图不存在 会先转成大写,没有大写名的表

select * from WSX; --查询错误 ORA-00942: 表或视图不存在 没有大写名的表

select * from `wsx`; --查询错误 ORA-00911: 无效字符 oracle不支持`(数字1左边的下键)

select * from `WSX`; --查询错误 ORA-00911: 无效字符 oracle不支持`(数字1左边的下键)

select * from "WSX"; --查询错误 ORA-00942: 表或视图不存在 没有大写名的表

## mysql环境测试 version:5.7

## 前提: 建立EDC表(表名大写)

select * from EDC; ##查询正确

select * from `EDC`; ##查询正确 支持的是`(数字1左边的下键)写法 不支持""这种写法

select * from edc; ##查询错误 1146 - Table 'test52060.edc' doesn't exist

select * from `edc`; ##查询错误 1146 - Table 'test52060.edc' doesn't exist

select * from "EDC"; ##查询错误 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"EDC"' at line 1

## 前提: 建立sdf表(表名小写)

select * from sdf; ##查询正确

select * from `sdf`; ##查询正确 支持的是`(数字1左边的下键)写法 不支持""这种写法

select * from SDF; ##查询错误 1146 - Table 'test52060.SDF' doesn't exist

select * from `SDF`; ##查询错误 1146 - Table 'test52060.SDF' doesn't exist

select * from "sdf"; ##查询错误 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"sdf"' at line 1 ""这种写法不支持

en, ok。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值