Show Table View Key(s)

UDA

Show Table View Key(s)

Apologies if this has been asked many times before.
I am trying to sum(budget_sales) from a table but when I join it onto another table it shows budget_sales in billions rather than in the more accurate hundreds of millions.
Do I need to join it onto the primary key/secondary key and if so what is the command to show a VIEW's keys?

Many thanks,

Roy
1 REPLY
Enthusiast

Re: Show Table View Key(s)

In teradata views just store sql and runs it against the base whenever you access that view.
I feel like you need materialized views, if it is correct then create join/aggregrate index which will act as materialized views in teradata and also lets you to define your own key on it. Good thing about them is teradata automatically manages it when ever base tables are update/del/inserted.

Example:
CREATE JOIN INDEX CustOrdIdx,
FALLBACK AS
SELECT c.CustId, c.Name, o.OrderDate, o.Status, o.Special
FROM Customer c LEFT JOIN Orders o
ON o.CustId = c.CustId
PRIMARY INDEX (CustId);