lightdb23.3 表名与包名不能重复

LightDB 表名与包名不能重复

从 LightDB 23.3 版本开始表名和包名不能重复,与 oracle 一致。原先已支持包名和schema名不能重复。

背景

在之前版本在同一schema 下可以创建相同名字的表和包。这会导致在存储过程中使用%type指定变量类型时,如果存在相同的表名和包名,会使用表的,可能会导致结果不符合预期;在表不存在的情况下才会引用包的。如下所示:

chuhx@test_o=# create table t1(key1 date);
CREATE TABLE
chuhx@test_o=# create package t1 IS
    key1 real;
    end;
/
CREATE PACKAGE
chuhx@test_o=#  declare
  val t1.key1%type = '20221212';
 begin
    dbms_output.serveroutput(true);
    dbms_output.put_line(cast(val as varchar2(100)));
end;
/
2022-12-12
DO
chuhx@test_o=# drop table t1;
DROP TABLE
chuhx@test_o=#  declare
  val t1.key1%type = '20221212';
 begin
    dbms_output.serveroutput(true);
    dbms_output.put_line(cast(val as varchar2(100)));
end;
/
2.0221212e+07
DO

在 oracle 下包名与表名不能相同,故需要支持此特性。

案例

lightdb@postgres=# create table t1(key1 int);
CREATE TABLE
lightdb@postgres=# create package t1 IS
        key1 real;
        end;
/
ERROR:  relation "t1" already exists
HINT:  A relation has the same name, so you must use a name that doesn't conflict with any existing relation.
lightdb@postgres=# drop table t1;
DROP TABLE
lightdb@postgres=# create package t1 IS
        key1 real;
        end;
/
CREATE PACKAGE
lightdb@postgres=# create table t1(key1 int);
ERROR:  package "t1" already exists
HINT:  A package has the same name, so you must use a name that doesn't conflict with any existing package.
lightdb@postgres=# 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

紫无之紫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值