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

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

问题描述

关于我的其他问题什么是最好的审核方法记录删除? 。 PostgreSQL相当于 CONTEXT_INFO 是什么?

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 记录为删除记录的用户。但是对于 INSERT UPDATE 来说,可以记录触发器的记录更改,因为您只需在其中添加用户字段即可。记录,例如 inserted_by last_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天全站免登陆