我可以检测Oracle中表的DDL的版本吗?
在 Informix 中,我可以从 systables 表中进行选择,并且可以调查其版本列以查看给定表的数字版本。此列随着影响给定表的每个 DDL 语句而递增。这意味着我能够查看自上次连接以来表的结构是否已更改。
Oracle中有类似的方法吗?
In Informix, I can do a select from the systables table, and can investigate its version column to see what numeric version a given table has. This column is incremented with every DDL statement that affects the given table. This means I have the ability to see whether a table's structure has changed since the last time I connected.
Is there a similar way to do this in Oracle?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
并不真地。 Oracle DBA/ALL/USER_OBJECTS 视图有一个 LAST_DDL_TIME 列,但它受结构更改以外的操作影响。
Not really. The Oracle DBA/ALL/USER_OBJECTS view has a LAST_DDL_TIME column, but it is affected by operations other than structure changes.
您可以使用跟踪表更改的 DDL 触发器来做到这一点(以及更多)。 此处有一篇有趣的文章和示例。
You can do that (and more) with a DDL trigger that keeps track of changes to tables. There's an interesting article with example here.
如果您确实想这样做,则必须使用 Oracle 的审核功能来审核更改。它可以很简单:
这至少会捕获成功的更改,忽略删除和创建。不幸的是,通过挖掘审计跟踪来展开表的历史结构堆栈留给了 Oracle 中的读者或许可变更管理包的练习。
您还可以通过编写在 DDL 语句上调用的系统事件触发器来进行自己的审计。如果您确实想了解发生了什么变化,那么您最终必须编写自己的 SQL 解析器。
If you really want to do so, you'd have to use Oracle's auditing functions to audit the changes. It could be as simple as:
That would at least capture the successfuly changes, ignoring drops and creates. Unfortunately, unwinding the stack of the table's historical strucuture by mining the audit trail is left as an exercise to the reader in Oracle, or to licensing the Change Management Pack.
You could also roll your own auditing by writing system-event triggers which are invoked on DDL statements. You'd end up having to write your own SQL parser if you really wantedto see what was changing.