想知道是否可以在一个插入声明中完成以下内容?
drop table analytics.bw_covariance_matrix;
create table analytics.bw_covariance_matrix (
row int,
x1 float,
x2 float,
x3 float
);
insert into analytics.bw_covariance_matrix VALUES
(1, 4.01926965, -0.4686067, -0.07592112),
insert into analytics.bw_covariance_matrix VALUES
(2, -0.46860675, 4.1799267, -0.82461139);
insert into analytics.bw_covariance_matrix VALUES
(3, -0.07592112, -0.8246114, 4.37186211);
答案 0 :(得分:5)
你可以UNION
一个SELECT有一个INSERT
语句:
insert into analytics.bw_covariance_matrix
SELECT 1, 4.01926965, -0.4686067, -0.07592112
UNION
SELECT 2, -0.46860675, 4.1799267, -0.82461139
UNION
SELECT 3, -0.07592112, -0.8246114, 4.37186211
我不相信Vertica有像MySQL和其他RDBMS这样的多记录插入语句,所以这是最好的选择。
答案 1 :(得分:1)
insert into analytics.bw_covariance_matrix VALUES
(1, 4.01926965, -0.4686067, -0.07592112),
(2, -0.46860675, 4.1799267, -0.82461139),
(3, -0.07592112, -0.8246114, 4.37186211);
请改为尝试:
INSERT INTO analytics.bw_covariance_matrix
SELECT row, x1, x2, x3
FROM analytics.bw_covariance_matrix
WHERE row IN (1,2,3)