テーブルへの最後の挿入Printer
でエラーが返されないのはなぜですか? 参照整合性のために拒否されると思いました(望んでいました)。
コード
CREATE TABLE IF NOT EXISTS
Client (
hostName TEXT PRIMARY KEY,
MACAddress TEXT NOT NULL,
deviceType TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS
Printer (
hostName TEXT NOT NULL REFERENCES Client(hostName),
outputType TEXT NOT NULL,
printerName TEXT NOT NULL,
PRIMARY KEY (hostname, outputType),
FOREIGN KEY (hostName) REFERENCES Client(hostName)
ON DELETE CASCADE
ON UPDATE CASCADE
);
insert into Client (hostName, MACAddress, deviceType)
values ('billlaptop.private.ycc', 'bc:ea:c5:13:b3:09','Client');
insert into Printer (hostName, outputType, printerName)
values ('billlaptop.private.ycc', 'Receipt', 'Thermal');
insert into Printer (hostName, outputType, printerName)
values ('xxxx.private.ycc', 'Receipt', 'Thermal');
select * from Printer;
出力
+--------------------------------------------------+
| hostName outputType printerName |
+--------------------------------------------------+
| billlaptop.private.ycc Receipt Thermal |
| xxxx.private.ycc Receipt Thermal |
+--------------------------------------------------+