This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-15. For the latest, interactive version please visit https://mariadb.com/kb/.

on duplicate key work around

Is there a clever way to simulate the on duplicate key behavior on a range of data apart from deleting the range and re-inserting?

CREATE TABLE cs1 (
    id              INT(10) UNSIGNED NOT NULL,
    `timestamp_`    DATETIME,
    numeric_val     DOUBLE DEFAULT NULL
) ENGINE=columnstore;

INSERT INTO cs1 VALUES (1, '2017-11-30 10:30:00', 13.13), ...
    ON DUPLICATE KEY UPDATE numeric_val = VALUES(numeric_val);

Answer Answered by David Thompson in this comment.

Since columnstore doesn't have unique indexes, then yes more or less. Another option is to load your inbound data into a staging table and then doing an insert select where you join and filter out the duplicates in what gets selected.

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.