[英]How to synchronize previously deleted rows
I have a junction/ many to many table in my database.我的数据库中有一个连接点/多对多表。 This table has 2 columns forming a composite primary key;
该表有 2 列构成复合主键; userid & groupid.
用户 ID 和组 ID。
I'm having an issue where once a row is deleted it can never be re-added and synced again.我遇到了一个问题,一旦一行被删除,就永远无法重新添加和同步。 For example:
例如:
I'm guessing that the scope knowledge is retaining the fact that the row was once deleted and not syncing changes to it?我猜测范围知识保留了该行曾经被删除而不同步更改的事实? Is this understanding correct?
这种理解是否正确? Is there anyway to clean this knowledge?
反正有没有清理这些知识?
If any of key columns have IDENTITY
property set, then you cannot simply insert values in such column.如果任何键列设置了
IDENTITY
属性,则您不能简单地在此类列中插入值。 You should use this property wisely - its idea it to ensure keys are never repeated.你应该明智地使用这个属性——它的想法是确保键永远不会重复。
So if you really need to insert values into IDENTITY
column use SET IDENTITY_INSERT MyTable ON/OFF
.因此,如果您确实需要将值插入
IDENTITY
列,请使用SET IDENTITY_INSERT MyTable ON/OFF
。 Only one table in a db can have this property set to ON. db 中只有一个表可以将此属性设置为 ON。 If it is off - an error occurs.
如果关闭 - 会发生错误。
CREATE TABLE MyTable (ID INT IDENTITY NOT NULL)
SET IDENTITY_INSERT MyTable ON/OFF
INSERT INTO MyTable VALUES (2)
SET IDENTITY_INSERT MyTable ON/OFF
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.