That was very useful. Thank you. So, let's say you want to insert/merge one record. Your plan of action would be: - 1. Create a temporary table and insert the data 2. Run the MERGE on the target table using field(s) other than ID since to find that for your temp, you would need to find it in the target at which point you will know whether or not you need to insert or update 3. Drop the temporary table - I hope I was clear enough on that. So, did I get the plan right?
If you had used UUIDs for the primary surrogate key, then you wouldn't have the problem of both of them having 5 because the probability of two rows having the same UUID is extremely low. That's why I always use UUIDs.
Thank you for sharing! It is interesting to know new techniques and functions.
Thanks, glad you enjoyed it!
That was very useful. Thank you.
So, let's say you want to insert/merge one record. Your plan of action would be:
-
1. Create a temporary table and insert the data
2. Run the MERGE on the target table using field(s) other than ID since to find that for your temp, you would need to find it in the target at which point you will know whether or not you need to insert or update
3. Drop the temporary table
-
I hope I was clear enough on that. So, did I get the plan right?
Yeah that sounds like it would work!
Thank you for the wonderful video sir, it is so helpful for me and my team, thanks again sir
You're welcome!
If you had used UUIDs for the primary surrogate key, then you wouldn't have the problem of both of them having 5 because the probability of two rows having the same UUID is extremely low. That's why I always use UUIDs.
Good point, that would have avoided this issue. I have a video coming soon on UUIDs that explains this benefit too.
Nothing, alternative for mysql then?
Yeah, there's a keyword or technique called INSERT ON DUPLICATE KEY UPDATE which I can make a video about in the future.