Oracle – 拒绝在 WHERE 子句中使用列

huangapple go评论59阅读模式
英文:

Oracle - denie columns in where clause

问题

在Oracle中,是否有一种方法可以禁用/限制/在使用where子句中某些列时进行警告?

我之所以问这个问题,是因为我有一个非常复杂的系统(跨越数百万行代码,包含成千上万个SQL语句,在敏感的生产环境中运行),与Oracle数据库一起工作,我需要从一个列迁移到另一个列,而该列是键的一部分(并且具有非常不唯一的名称)。

简单的搜索是不可能的...
我正在进行的步骤如下:

  1. 填充新列
  2. 每当第一个列上有索引时,在第二个列上添加索引。
  3. 将所有在where子句中使用的旧列更改为新列
  4. 停止从第一个列中读取
  5. 停止向第一个列中写入
  6. 删除该列

我目前已完成第3步,希望验证我是否已找到所有情况。

英文:

Is there a way to disable/restrict/alert-when-using some column in Oracle in a where clauses?

The reason that I'm asking this is because I have a very complex system (~30 services span cross millions of lines of code with thousends of sqls in it, in a sensitive production environment) working with an Oracle DB I need to migrate from using one column that is part of a key (and have a very not uniqu name) to another column.

Simple search is impossible....
The steps I'm having are:

  1. populate new column
  2. Add indexes on with the second column whenever there's an index with the first one.
  3. Migrate all uses in where caluses from old to new column
  4. Stop reading from the first column
  5. Stop writing to the first column
  6. Delete the column

I'm currently done step 3 and want to verify I've found all of the cases.

答案1

得分: 1

所以,你正在用另一个列替换一个列。你完成后期望得到什么好处?这将如何改善该应用程序的整体体验?我希望这将值得努力。

至于你的问题:查询user_source(或将其扩展到all_source甚至dba_source,但你需要额外的权限来执行此操作),看看那个非常不唯一的名称在哪里使用。类似这样的:

SQL> select * from user_source where lower(text) like '%empno%';

NAME            TYPE          LINE TEXT
--------------- ------------ ----- --------------------------------------------------------------------------------
P_RAISE         PROCEDURE       22        WHERE empno = par_empno;
P_RAISE         PROCEDURE       14     WHERE empno = par_empno;
P_RAISE         PROCEDURE        1 PROCEDURE p_raise (par_empno IN emp.empno%TYPE)
GET_LIST        FUNCTION         7          'select empno, ename, job, sal from emp where deptno = 10 order by '
英文:

So, you're replacing one column with another. Which benefit do you expect once you're done? How will that improve overall experience with that application? I hope it is worth the effort.

As of your question: query user_source (or expand it to all_source or even dba_source, but you'll need additional privileges to do that) and see where's that very not unique name used. Something like this:

SQL> select * from user_source where lower(text) like '%empno%';

NAME            TYPE          LINE TEXT
--------------- ------------ ----- --------------------------------------------------------------------------------
P_RAISE         PROCEDURE       22        WHERE empno = par_empno;
P_RAISE         PROCEDURE       14     WHERE empno = par_empno;
P_RAISE         PROCEDURE        1 PROCEDURE p_raise (par_empno IN emp.empno%TYPE)
GET_LIST        FUNCTION         7          'select empno, ename, job, sal from emp where deptno = 10 order by '

SQL>

huangapple
  • 本文由 发表于 2023年1月9日 14:14:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/75053731.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定