参照†
更新†
リーフを追加する†
- :objectを:target下に
UPDATE 02_DIRECTORY Target INNER JOIN 02_DIRECTORY Shift ON Shift.R >= Target.R SET Shift.R = Shift.R + 2 , Shift.L = CASE WHEN Shift.L > Target.L THEN Shift.L + 2 ELSE Shift.L END WHERE Target.DIRECTORY_ID = :target; INSERT INTO 02_DIRECTORY SELECT :object, R-2 AS L, R-1 AS R FROM 02_DIRECTORY WHERE DIRECTORY_ID = :target;
部分木を移動する†
- :objectを:target下に
UPDATE 02_DIRECTORY Target INNER JOIN 02_DIRECTORY Shift ON Shift.R >= Target.R INNER JOIN 02_DIRECTORY Object ON Object.DIRECTORY_ID = :object SET Shift.R = Shift.R + (Object.R - Object.L + 1) , Shift.L = CASE WHEN Shift.L > Target.L THEN Shift.L + (Object.R - Object.L + 1) ELSE Shift.L END WHERE Target.DIRECTORY_ID = :target; UPDATE 02_DIRECTORY Target INNER JOIN 02_DIRECTORY Object ON Object.DIRECTORY_ID ='!' INNER JOIN 02_DIRECTORY Shift ON Shift.L >= Object.L AND Shift.R <= Object.R SET Shift.L = Target.R - (Object.R - Object.L + 1) , Shift.R = Target.R - 1 WHERE Target.DIRECTORY_ID = :target;