Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Ich bekomme in einem Sql Script welches mir auf dem MS SQL Server 2012 eine Datenbank mit vielen Tabellen erzeugen soll mehrere Fehler das durch die Updateweitergabe auf Foreign Keys Schleifen oder mehrere Kaskadenpfade auftreten können.

Allerdings verstehe ich nicht so ganz warum.

Als Beispiel für einen der Fälle


ALTER TABLE [TableA] WITH CHECK ADD CONSTRAINT [TableA_FK00] FOREIGN KEY([SomeID], [SomeOtherID])
REFERENCES [TableB] ([SomeID], [SomeOtherID])
ON UPDATE CASCADE
GO

ALTER TABLE [TableA] WITH CHECK ADD CONSTRAINT [TableA_FK01] FOREIGN KEY([TableCID])
REFERENCES [TableC] ([TableCID])
ON UPDATE CASCADE
GO
[/PHP]

Es gibt also in TableA zwei unterschiedliche FKs auf unterschiedliche Tabellen mit unterschiedlichen Spalten. Mache ich bei einem der beiden Constraints das ON UPDATE CASCADE weg verschwindet auch der Fehler für diese Tabelle.

Die MSDN sagt dazu

The series of cascading referential actions triggered by a single DELETE or UPDATE must form a tree containing no circular references. No table can appear more than once in the list of all cascading referential actions that result from the DELETE or UPDATE. The tree of cascading referential actions must not have more than one path to any given table. Any branch of the tree is terminated when it encounters a table for which NO ACTION has been specified or is the default.

und genau deswegen verstehe ich das nicht. Wird in obigem Beispiel SomeID oder SomeOtherID geändert ist das 2. Constraint nicht davon betroffen. Wird hingegen TableCID geändert dann ist das erste Constraint nicht betroffen.

Warum also der Fehler?

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.