PostgreSQL 相当于 SQL Servfer 的 CONTEXT_INFO 是什么? [英] What's the PostgreSQL equivalent of SQL Servfer's CONTEXT_INFO?

查看:23
本文介绍了PostgreSQL 相当于 SQL Servfer 的 CONTEXT_INFO 是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于我的另一个问题 审计的最佳方式是什么日志删除?".CONTEXT_INFO 的 PostgreSQL 等价物是什么?

In relation to my other question "What’s the best way to audit log DELETEs?". What's the PostgreSQL equivalent of CONTEXT_INFO?

我想使用触发器记录删除,但由于我没有将数据库用户用作应用程序的逻辑用户,因此我无法将触发器代码中的 CURRENT_USER 记录为删除记录.但是对于 INSERTUPDATE 可以从触发器记录记录更改,因为您只需在记录中添加一个用户字段,例如 inserted_bylast_updated_by,并使用这些字段记录到审计表.

I want to log deletes using a trigger, but since I'm not using the database user as my app's logical user, I cannot log the CURRENT_USER from the trigger code as the user who deleted the record. But for INSERT and UPDATE it is possible to log the record changes from trigger since you can just add a user field in the record, say inserted_by and last_updated_by, and use these fields to log to audit table.

推荐答案

http://www.postgres.cz/index.php/PostgreSQL_SQL_Tricks_II#Any_other_session_variables

PostgreSQL 提供了更多的变种,请看这个网站.

PostgreSQL provides more variants, please, look to this site.

这篇关于PostgreSQL 相当于 SQL Servfer 的 CONTEXT_INFO 是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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