查找Oracle中的列是否有序列 [英] Find if a column in Oracle has a sequence

查看:229
本文介绍了查找Oracle中的列是否有序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图确定是否从序列中填充了Oracle中的列.我对Oracle处理序列的印象是序列和列是单独的实体,需要手动插入下一个序列值,例如:

insert into tbl1 values(someseq.nextval, 'test')

或将其放入表触发器中.这意味着判断是否从序列中填充了列是很重要的.那是对的吗?关于如何确定是否从序列中填充列的任何想法?

解决方案

您是对的;该序列与表是分开的,并且可以使用单个序列来填充任何表,并且某些表中一列中的值可能主要来自一个序列(或一组序列),但手动生成的值除外. /p>

换句话说,列和序列之间没有强制连接-因此无法从架构中发现这种关系.

最终,将分析所有在表中插入或更新数据的应用程序的源代码.没有其他保证.如果存在存储过程是对表进行修改的唯一方法,或者存在用于设置值的触发器或其他类似的东西,则可以减小搜索范围.但是一般的解决方案是分析来源"的非解决方案".

I am attempting to figure out if a column in Oracle is populated from a sequence. My impression of how Oracle handles sequencing is that the sequence and column are separate entities and one needs to either manually insert the next sequence value like:

insert into tbl1 values(someseq.nextval, 'test')

or put it into a table trigger. Meaning that it is non-trivial to tell if a column is populated from a sequence. Is that correct? Any ideas about how I might go about figuring out if a column is populated from a sequence?

解决方案

You are correct; the sequence is separate from the table, and a single sequence can be used to populate any table, and the values in a column in some table may mostly come from a sequence (or set of sequences), except for the values manually generated.

In other words, there is no mandatory connection between a column and a sequence - and therefore no way to discover such a relationship from the schema.

Ultimately, the analysis will be of the source code of all applications that insert or update data in the table. Nothing else is guaranteed. You can reduce the scope of the search if there is a stored procedure that is the only way to make modifications to the table, or if there is a trigger that sets the value, or other such things. But the general solution is the 'non-solution' of 'analyze the source'.

这篇关于查找Oracle中的列是否有序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆