【发布时间】:2022-01-28 08:48:37
【问题描述】:
我正在寻找一种方法来告知不应再使用 oracle 表。 它仍在使用中,因此我不能将标记用作表列的 UNUSED,因为它会引发异常,但只是为了让开发人员知道从现在开始他不应该使用它。
【问题讨论】:
-
我认为开发人员——作为 开发人员——已经知道该表不会被使用,并且会参与删除来自测试系统的表,然后是生产系统。
我正在寻找一种方法来告知不应再使用 oracle 表。 它仍在使用中,因此我不能将标记用作表列的 UNUSED,因为它会引发异常,但只是为了让开发人员知道从现在开始他不应该使用它。
【问题讨论】:
创建评论?
comment on table emp is '30.12.2021, shagby: do not use that table any more';
或者,创建一个触发器:
SQL> create or replace trigger trg_test
2 before insert or update or delete on test
3 begin
4 raise_application_error(-20000, '30.12.2021, shagby: do not use that table any more');
5 end;
6 /
Trigger created.
SQL> delete from test;
delete from test
*
ERROR at line 1:
ORA-20000: 30.12.2021, shagby: do not use that table any more
ORA-06512: at "SCOTT.TRG_TEST", line 2
ORA-04088: error during execution of trigger 'SCOTT.TRG_TEST'
SQL> insert into test (col) values ('x');
insert into test (col) values ('x')
*
ERROR at line 1:
ORA-20000: 30.12.2021, shagby: do not use that table any more
ORA-06512: at "SCOTT.TRG_TEST", line 2
ORA-04088: error during execution of trigger 'SCOTT.TRG_TEST'
SQL> update test set col = 'y';
update test set col = 'y'
*
ERROR at line 1:
ORA-20000: 30.12.2021, shagby: do not use that table any more
ORA-06512: at "SCOTT.TRG_TEST", line 2
ORA-04088: error during execution of trigger 'SCOTT.TRG_TEST'
SQL>
【讨论】:
DECLARE PRAGMA DEPRECATE(TRG_TEST, 'The underlying table is deprecated.'); 时,包本身会发出警告PLW-06022: cannot use PRAGMA DEPRECATE on this entity。