Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Teradata Cookbook

You're reading from   Teradata Cookbook Over 85 recipes to implement efficient data warehousing solutions

Arrow left icon
Product type Paperback
Published in Feb 2018
Publisher Packt
ISBN-13 9781787280786
Length 454 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (3):
Arrow left icon
 Khandelwal Khandelwal
Author Profile Icon Khandelwal
Khandelwal
 Kasi Kasi
Author Profile Icon Kasi
Kasi
 Bhamidipati Bhamidipati
Author Profile Icon Bhamidipati
Bhamidipati
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Title Page
Dedication
Packt Upsell
Contributors
Preface
1. Installation FREE CHAPTER 2. SQLs 3. Advanced SQL with Backup and Restore 4. All about Indexes 5. Mixing Strategies – Joining of Tables 6. Building Loading Utility – Replication and Loading 7. Monitoring the better way 8. Collect Statistics the Better Way 9. Application and OPS DBA Insight 10. DBA Insight 11. Performance Tuning 12. Troubleshooting 1. Other Books You May Enjoy Index

Performing MERGE INTO


MERGE statements can be used as an alternative to update statements. Updating rows is a CPU and I/O intensive operation, and, if you are updating PI on a big table which does not have a partition column, then updating columns becomes a challenge.

Getting ready

To complete this recipe you need to connect to the Teradata database and open SQLA.

How to do it...

  1. Create a source table with the following definition and containing a million rows:
CREATE volatile TABLE MergingTable_Source (
ID DECIMAL(18,0),
END_DT DATE,
SOLD_AMT int
)
UNIQUE PRIMARY INDEX (ID) on commit preserve rows;
  1. Create a target table with the following DDL:
CREATE volatile TABLE MergingTable_Target ( 
ID DECIMAL(18,0),
END_DT DATE,
SOLD_AMT int
)
UNIQUE PRIMARY INDEX (ID);
  1. We will insert in the following MergingTable_Target table if the ID from MergingTable_Source does not exist. And if it does, we will update the END_DT and SOLD_AMT columns:
MERGE INTO MergingTable_Target t
USING MergingTable_Source       s...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images