Duplicate Row Warning: Teradata

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
horserider
Participant
Posts: 71
Joined: Mon Jul 09, 2007 1:12 pm

Duplicate Row Warning: Teradata

Post by horserider »

I have a flat file that goes into a TERADATA Table in a parallel job. The TERADATA Table has NON UNIQUE KEY. But when I load the source data into the target table the Director displays warnings about the duplicate rows and rejects them.

When I am creating teradata table and the index in NON-UNIQUE, why does DataStage rejects duplicate rows? How to address this issue?

I am using Teradata PX Stage to load the data.
throbinson
Charter Member
Charter Member
Posts: 299
Joined: Wed Nov 13, 2002 5:38 pm
Location: USA

Post by throbinson »

Please post the exact message. Why do you think it is being generated by DataStage and not Teradata?
horserider
Participant
Posts: 71
Joined: Mon Jul 09, 2007 1:12 pm

Post by horserider »

I guess I should have been specific.

I don't know if it's teradata or datastage that is rejecting the row. This is the DDL to create Table.

CREATE SET TABLE EMPLOYEE_STG ,NO FALLBACK
(
YR_MTH CHAR(6),
AD_CO_NBR CHAR(5),
DLR_PA_C CHAR(5),
DLR_NBR CHAR(5),
VIN CHAR(17),
AMOUNT DECIMAL(9,2),
VO_CD CHAR(1),
R_DT CHAR(6),
ADV_REC CHAR(2),
DATE_UPDATE_Y DATE NOT NULL DEFAULT DATE,
TIME_UPDATE_M TIME(0) NOT NULL DEFAULT CURRENT_TIME(0)
)
PRIMARY INDEX PRIMARY_KEY (YR_MTH, AD_CO_NBR,DLR_PA_C,VIN);
;

Since I am not defining as UNIQUE PRIMARY KEY, my guess was I should have been able to insert duplicate data. I am really surprised to see that Teradata doesn't allow to insert duplicate rows as we see in DB2, Oracle, SQL Server and other databases
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Is there not an automatic "jointly unique" constraint added when you include PRIMARY KEY in a CREATE TABLE statement?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
throbinson
Charter Member
Charter Member
Posts: 299
Joined: Wed Nov 13, 2002 5:38 pm
Location: USA

Post by throbinson »

It is the difference between a set table and a multi-set table. A set table refers to set theory which mandates that each tuple be unique. If you don't want that then define the table as a multi-set table which will allow multiple "sets" of data.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

And a set table is the default, is it not? Therefore horserider's DDL will create a set table which will enforce uniqueness of keys.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
throbinson
Charter Member
Charter Member
Posts: 299
Joined: Wed Nov 13, 2002 5:38 pm
Location: USA

Post by throbinson »

It will enforce uniqueness of keys indirectly since it is enforcing uniqueness of the entire row (set) when defining the default as a set table. I took his question to be why doesn't Teradata behave like other DBMSs where rows can be duplicated until the cows come home as long as the Primary key is non-unique or even missing.
This is the difference between set and multi-set tables in Teradata.
Uniqueness is not strictly a "key" concept in Teradata. It is also a row concept when defining a set table.
Post Reply