我需要一个表格表格来保存像这样的层次结构树数据(即大陆,国家,城市)
id name parent
-------------------
1 world null
2 Europe 1
3 Asia 1
4 France 2
5 Paris 4
6 Lyon 4
Run Code Online (Sandbox Code Playgroud)
我要删除France,希望该表可以级联删除所有法国城市。但是当我像这样创建表时
create table locations
(
id int identity(1, 1),
name varchar(255) not null,
parent_id int,
constraint pk__locations
primary key clustered (id),
constraint fk__locations
foreign key (parent_id)
references locations (id)
on delete cascade
on update no action
)
Run Code Online (Sandbox Code Playgroud)
我有一个错误
在表“位置”上引入外键约束“ fk__locations”可能会导致循环或多个级联路径。指定ON DELETE NO ACTION或ON UPDATE NO ACTION,或修改其他FOREIGN KEY约束。
信息说
ON DELETE NO ACTION-这正是我想要的我正在尝试使用 TRegistry.SaveKey 或 RegSaveKey 函数导出注册表项,但没有成功。我得到的只是一个空文件 0 字节。我在网上看到过例子,似乎没有人在 Windows10 上工作。
reg := TRegistry.Create;
reg.RootKey := HKEY_CURRENT_USER;
reg.Access := KEY_ALL_ACCESS;
if reg.OpenKey('\Software\MyCompanyName\MyApplication\', True) then
begin
reg.WriteInteger('background', Self.Color);
reg.SaveKey('HKEY_CURRENT_USER\Software\MyCompanyName\MyApplication', 'test.txt'); //not working
RegSaveKey(reg.CurrentKey, 'test.reg', nil); //creates empty file
end;
reg.CloseKey;
reg.Free;
Run Code Online (Sandbox Code Playgroud)
此外,如果我从 RegEdit 中提取现有密钥,然后尝试使用 TRegistry.LoadKey 或 RegLoadKey 将其加载到应用程序中,则不会发生任何事情
我在运行它的机器上确实拥有管理员权限。
有熟悉这个问题的人吗?