我试图从没有引用的表中删除一行,并得到“外键不匹配”。即我得到一个表,其中值说a,b引用另一个表的值,假设a1,b1。我正在尝试删除引用其他一些值但未引用的值a,b。
>Create Table Sensor(
SensorId INT,RoomId int NOT NULL,MoistureMeasurementPrecision DOUBLE,HeatMeasurementPrecision double,MaximumBatteryLife double,Manufacturer varchar(20),Primary key(SensorId,RoomId),Foreign key(RoomId) references Room(RoomId),Check (MoistureMeasurementPrecision > 0 & MoistureMeasurementPrecision *<=100),Check (HeatMeasurementPrecision > 0 & HeatMeasurementPrecision <=100),Check (MaximumBatteryLife>0));
Create Table Measurement(
TimeofMeasurement TIME,RoomId INT NOT NULL,SensorId INT NOT NULL,Heat DOUBLE,Moisture DOUBLE,primary key(RoomId,SensorId,TimeofMeasurement),foreign key(RoomId) references Sensor(RoomId),foreign key(SensorId) references Sensor(SensorId),check(Moisture>0));
sqlite>从其中RoomId = 1;
的Measurement中删除错误:外键不匹配-引用“传感器”的“度量”
在sqlite Studio上尝试相同的操作并得到以下错误:[21:53:30]在数据库“第一个数据库”上执行SQL查询时出错:外键不匹配-引用“传感器”的“测量”。