我在表中有一列包含以下格式的JSON字符串。
Click Here for image of JSON column
{“uuid”:“633ba45145f58a40”,“model”:“HM NOTE 1LTE”,“platform”:“Android”,“version”:“4.4.4”,“frontCameraAvailable”:“true”}
现在我想将此数据迁移到具有以下模式的表中
CREATE TABLE OfflineAppDeviceInfo (
id INT PRIMARY KEY NOT NULL,
deviceId INT NOT NULL,
uuid VARCHAR(255),
model VARCHAR(65),
platform VARCHAR(65),
version VARCHAR(65),
frontCameraAvailable BIT,
FOREIGN KEY (deviceId) REFERENCES DeviceSecurity (deviceId)
);
Click here for OfflineAppDeviceInfo table
现在我已经有了一个解析JSON的SQL脚本
select d.deviceID,NAME,StringValue
from DeviceSecurity d
cross apply udf_parseJSON_support(d.deviceInfoJson)
where name != '-'
and d.deviceInfoJson is not null
Click here for the result of the above script being run
但是如何使用SQL脚本将其迁移到OfflineAppDeviceInfo表中。我知道这可以用JAVA代码完成,但我要求只用SQL来完成。这甚至可能吗?