如何监控和记录所有 SQL 插入命令
我正在使用 Oracle SQL Dev 2.1.1.64
我使用使用 Oracle 数据库进行存储的应用程序。 SQL Dev 有什么办法吗?监视并记录从 Web 应用程序“传入”数据库的所有插入命令?你能告诉我该怎么做吗?
I am using Oracle SQL Dev 2.1.1.64
I work with application that uses oracle database for storage.
Is there any way in SQL Dev. to monitor and log all the insert commands that are "coming" from the web application into database? Can you tell me how to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
应该可以帮助你开始。
请务必根据需要设置参数
audit_trail
和audit_file_dest
。之后,您可以在
sys.aud$
或audit_file_dest
指定的目录中找到操作。您还可以查看
细粒度审核
,但从您的问题来看,使用细粒度审核(FGA)似乎有点矫枉过正。should get you started.
Be sure to set the parameters
audit_trail
andaudit_file_dest
as you need them.After that, you find the operations either in
sys.aud$
or in the directory specified byaudit_file_dest
.There is also
fine grained auditing
into which you might take a look, but from your question, using fine grained auditing (FGA) would seem to be overkill.您可以为要监视的表编写触发器。如果您仅对来自 Web 应用程序的插入查询感兴趣,则可以检查访问表的某些特定用户名/架构的触发器,并使用该用户名作为您的 Web 应用程序凭据。
或者,您也可以使用 Oracle 的审核功能。不过,它需要一点 Oracle 数据库管理知识才能实现......
You can write a trigger for the tables you want to monitor. If you are only interested on the insert queries coming from the Web Application, you can check on the trigger for some specific username/schema accessing the table, and use that username as your web application credentials.
Alternatively you can also use Oracle's AUDIT feature. It requires a little bit of Oracle Database Administration knowledge to implement though...
您可以查询 v$SQL,但您需要拥有相关的 GRANTS 才能执行此操作。
对于长时间运行的会话,您还可以使用 v$session_longops 监视进度,
希望这对您有帮助。
You could query v$SQL, but you would need to have the relevant GRANTS to enable you to do this.
For long running sessions you can also monitor progress using v$session_longops
hope this helps you.
创建一个触发器,每当表中的数据发生更改(插入、更新、删除)时,该触发器都会写入日志表。
删除前、插入后、更新后触发器就是您想要的。
它不会专门只记录 Web 应用程序,但如果您记录用户所做的更改,您将能够在查看数据时对其进行过滤。
Create a trigger that writes to a journaling table whenever a change of data in the table happens (insert, update, delete).
Before delete, after insert, after update triggers are what you want.
It won't specifically log only the web application, but if you log the user making the change you will be able to filter on that when viewing the data.