问题
I am very new to Teradata (1 week) and my primary skillset is SQL Server. I am pulling data from one of the TeraData tables to SQL Server table and the TD table has an Identity column with negative values. I looked at the DDL for that table and it does not mention a start with and end with values.
So, how does TeraData have the negative values in there? Also, if I pull this over to SQL Server, should I create a new Identity Column or should I just maintain the Identity values I get from TeraData?
回答1:
If the column is defined as GENERATED BY DEFAULT
the negative values might have been inserted directly.
If it's GENERATED ALWAYS
without NO CYCLE
and the MAXVALUE
has been reached it will start again at the MINVALUE
, by default min and max are based on the possible range of the datatype.
IDENTITY columns are hardly used in Teradata, decide based on your needs if you need to keep them.
回答2:
A -1 or zero is often used in a data warehouse identity column as a place holder so the Fact foreign key is not null. It speeds up joins and you know it was there on purpose.
来源:https://stackoverflow.com/questions/26409717/why-does-teradata-identity-column-have-negative-values