暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

LightDB23.3新特性 Oracle兼容模式字段名、表名默认转大写

原创 姚崇 2023-08-29
187

Oracle对象名在不使用引号的情况下, 默认转换为大写, lightdb默认小写, 包括ddl. 所以当sql包含引号时, oracle的sql在lightdb下使用, 会出现对象不存在的错误.

Oracle数据库中现象

如下表明Oracle模式字段和表名底层存储为大写存储

CREATE table tb(id int);
select "id" from "tb"; --报错 tb表或视图不存在 
SQL> select "id" from "tb";
select "id" from "tb"
                 *
ERROR at line 1:
ORA-00942: table or view does not exist


select "id" from "TB"; --报错 标识符id无效
SQL> select "id" from "TB";
select "id" from "TB"
       *
ERROR at line 1:
ORA-00904: "id": invalid identifier

select "ID" from "TB"; --正确
SQL> select "ID" from "TB";

no rows selected

而LightDB或者PG中,默认底层存储为小写

lightdb@postgres=# CREATE table tb(id int);
CREATE TABLE
lightdb@postgres=# select "id" from "tb";
 id 
----
(0 rows)

lightdb@postgres=# select "id" from "TB";
ERROR:  relation "TB" does not exist
LINE 1: select "id" from "TB";
                         ^
lightdb@postgres=# select "ID" from "TB";
ERROR:  relation "TB" does not exist
LINE 1: select "ID" from "TB";
                         ^

那么从LightDB 23.3开始最次做了兼容支持

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论