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=# 

你可能感兴趣的:(lightdb,数据库,oracle,lightdb,包,表)