Created
November 18, 2018 15:27
-
-
Save bliiir/5cb0b360ace7b43986990f903baca8c8 to your computer and use it in GitHub Desktop.
Postgres database: Merge two tables using composite key constraints and Insert statement in what is know as an UPSERT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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