【问题标题】:is there any ORA message that table is deprecated?是否有任何 ORA 消息表明该表已弃用?
【发布时间】:2022-01-28 08:48:37
【问题描述】:

我正在寻找一种方法来告知不应再使用 oracle 表。 它仍在使用中,因此我不能将标记用作表列的 UNUSED,因为它会引发异常,但只是为了让开发人员知道从现在开始他不应该使用它。

【问题讨论】:

  • 我认为开发人员——作为 开发人员——已经知道该表不会被使用,并且会参与删除来自测试系统的表,然后是生产系统。

标签: java sql oracle oracle11g


【解决方案1】:

创建评论?

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>

【讨论】:

  • 很好的解决方案!我打算建议“让开发人员知道从现在开始他不应该使用它”的非技术解决方案。将向开发人员发送一封电子邮件,通知他! :-)
  • 这(我的建议)也不完美,@Eds。如果所有开发人员都在同一个模式中工作,他们可以删除触发器或删除评论。因此,我想给他们发一封电子邮件不会有什么坏处 :) 此外,你会有一个证据他们被告知!
  • 有一个“弃用”特性,但它只适用于一些 PL/SQL 对象。我尝试弃用触发器,希望依赖对象随后会引发错误,但显然不能弃用触发器。当我添加DECLARE PRAGMA DEPRECATE(TRG_TEST, 'The underlying table is deprecated.'); 时,包本身会发出警告PLW-06022: cannot use PRAGMA DEPRECATE on this entity
猜你喜欢
  • 2011-08-16
  • 1970-01-01
  • 1970-01-01
  • 2011-06-20
  • 1970-01-01
  • 2018-09-18
  • 2015-10-13
  • 2014-10-19
  • 2023-03-06
相关资源
最近更新 更多