SQL触发器:在主键更新时,如何确定哪个“已删除”?记录对应于“插入”到哪个记录。记录? [英] SQL Trigger: On update of primary key, how to determine which "deleted" record cooresponds to which "inserted" record?

查看:84
本文介绍了SQL触发器:在主键更新时,如何确定哪个“已删除”?记录对应于“插入”到哪个记录。记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我知道更新主键是不好的。

Assume that I know that updating a primary key is bad.

还有其他一些问题表明已插入已更新表记录按位置匹配(一个匹配第一个匹配。)这是事实还是巧合?

There are other questions which imply that the inserted and updated table records match by position (the first of one matches the first of the other.) Is this a fact or coincidence?

当主键在更新时更改时,是否有任何东西可以将两个表连接在一起?

Is there anything that could join the two tables together when the primary key changes on an update?

推荐答案

插入的+删除的虚拟表行位置不匹配

There is no match of inserted+deleted virtual table row positions.

不,您不能匹配行

一些选项:


  • 还有另一个唯一不变的键(用于该更新)来链接行

  • 限制为单行操作。

  • 使用带有OUTPUT子句的存储过程来捕获键之前和之后

  • 带有OUTPUT子句的INSTEAD OF触发器(TBH不确定是否可以这样做)

  • 禁止主键更新(在注释后添加)

  • there is another unique unchanging (for that update) key to link rows
  • limit to single row actions.
  • use a stored procedure with the OUTPUT clause to capture before and after keys
  • INSTEAD OF trigger with OUTPUT clause (TBH not sure if you can do this)
  • disallow primary key updates (added after comment)

这篇关于SQL触发器:在主键更新时,如何确定哪个“已删除”?记录对应于“插入”到哪个记录。记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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