Skip to content

Instantly share code, notes, and snippets.

@bliiir
Created Nov 18, 2018
Embed
What would you like to do?
Postgres database: Merge two tables using composite key constraints and Insert statement in what is know as an UPSERT
INSERT INTO bucket(
market_id,
timeframe_id,
time_close,
price_open,
price_high,
price_low,
price_close,
volume)
SELECT
market_id,
timeframe_id,
time_close,
price_open,
price_high,
price_low,
price_close,
volume
FROM bucket_temp
ON CONFLICT (market_id, timeframe_id, time_close) DO NOTHING;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment