I have a process of moving rows from one database to another. Due to some circular chains of foreign key references, I cannot delete rows from the old database and not insert them into the new database.
Since the entire operation is performed in transaction 1, I want SQL Server to ignore referential integrity failures until I call COMMIT TRANSACTION.
COMMIT TRANSACTION
For example, 2 :
Table: Turboencabulators Table: Marselvanes ========================= ======================= PK TurboencabulatorID int /-> PK MarselvaneID int ^ MarselvanesID int --/ HasGrammeter bit | PantametricFan varchar(50) +------------------------------- TurboencabulatorID int
If I try to insert a turbocharger in a new table, it will fail if there is no more marselvane. Reverse ordering has the same problem.
When I try to delete old lines, I cannot delete one until the other is deleted.
n - , , , null. , . , , , FK, . 3
, , - T-SQL, SQL Server , commit.
123
...
ALTER TABLE whatever_table NOCHECK CONSTRAINT ALL
, ...
ALTER TABLE whatever_table CHECK CONSTRAINT ALL
.
-don
, .
, lookups/checks/cascade, //. , FK: "" FK. , - , . " , ", , , . , , ? , , , corrcetive : , . , , - , , . , .
, , - , . A FK B. , B, A, A, B, . FK , FK . , , !
, , , cascadin hierachy . CS- , . , . , NULL post insert.
, - no-no: , , . "" , ( , ).
Source: https://habr.com/ru/post/1734618/More articles:Encoding the minimum characters in a POST request: is it safe or not? - postCannot Connect to MS Access Database via JDBC on Win 7 64-bit - ms-access-2007Question for iPhone dev noob: invoke an action explicitly when the application starts - objective-chow to use ForeignKeyRawIdWidget - djangoProblem with fullscreen OpenGL on Mac - cocoaHow do you return a 2d array in C ++? - c ++Как преобразовать строку JSON в массив (PHP)? - objectОшибка Makefile с файлами, начинающимися с "#" - makefileCan C ++ policy classes indicate the existence / absence of constructors? - c ++How to create an Office add-in without registering with the build system? - visual-studio-2008All Articles