Send feedback on this topic.
Teradata.Client.Provider
Data Type Mappings
.NET Data Provider for Teradata > Developer's Guide > Data Types > Data Type Mappings

The ADO.NET Specifications utilizes three different Type Declarations:

  1. .NET Type, for example Type object for System.Int32, System.Decimal and Teradata.Client.Provider.TdDecimal. The TdDataReader.GetFieldType and TdDataReader.GetProviderSpecificFieldType methods return a System.Type object.

  2. ADO.NET DB Type (System.Data.DbType), for example DbType.Int32, DbType.Decimal and DbType.DateTime. DbType is used to declare the type of Parameters (TdParameter.DbType ).

  3. Provider Type (TdType), for example TdType.Integer, TdType.Decimal and TdType.Timestamp. Provider Type is used to declare the type of Parameters (TdParameter.TdType) or identify the data type returned by TdDataReader (TdDataReader.GetSchemaTable) class.

The ADO.NET Specification supports two groups of Data Types:

  1. Base Class Library (BCL) Types that comply to the Common Language Specification (CLS). These types include System.Byte, System.Int16, System.Int32, System.Int64, System.Char, System.Single, System.Double, System.Boolean, System.Decimal, Sysetm.String and System.Object. BCL types are accessible from TdDataReader.GetValue, TdDataReader.GetValues, TdParameter.Value and Typed Accessor methods.

  2. Provider Specific Types that comply to the Common Language Specification, for example TdDecimal value type. Refer to the .NET Data Provider for Teradata Provider Specific Types for additional information. Provider Specific types are accessible from TdDataReader.GetProviderSpecificValue, TdDataReader.GetProviderSpecificValues, TdParametere.ProviderSpecificValue and Typed Accessor methods.

Some Provider Specific types do not have a corresponding DbType type declaration or BCL type. For example the Teradata Database 13.0 and higher supports PERIOD data types and the .NET Data Provider for Teradata version 13.0 and higher has PERIOD Provider Specific Types (e.g. TdPeriodDate). The Data Provider supports conversion from Provider Specific type to System.String whenever possible.

The following tables shows the mapping of the SQL types to BCL types, DbType and TdType type declarations.

SQL Type TdType Enumeration BCL Type DbType Enumeration
Character and CLOB Data Types Char Char String
Char[]
StringFixedLength
Clob Clob String
Char[]
String
Graphic Graphic String
Char[]
StringFixedLength
Json Json String
Char[]
Json
VarChar VarChar String
Char[]
String
VarGraphic VarChar String
Char[]
String
Byte and BLOB Data Types Blob Blob Byte[] Binary
Byte Byte Byte[] Binary
VarByte VarByte Byte[] Binary
Numeric Data Types BigInt BigInt Int64 Int64
ByteInt ByteInt Int16 SByte
Decimal Decimal Decimal Decimal
Double Double Double Double
Integer Integer Int32 Int32
Number Number Double Double
SmallInt SmallInt Int16 Int16
Date and Time Data Types Date Date DateTime Date
Time Time TimeSpan Time
Time With Time Zone TimeWithZone String String
Timestamp Timestamp DateTime DateTime
Timestamp With Time Zone TimestampWithZone DateTimeOffset DateTimeOffset
Interval Data Types Interval Day IntervalDay TimeSpan Object
Interval Day To Hour IntervalDayToHour TimeSpan Object
Interval Day To Minute IntervalDayToMinute TimeSpan Object
Interval Day To Second IntervalDayToSecond TimeSpan Object
Interval Hour IntervalHour TimeSpan Object
Interval Hour To Minute IntervalHourToMinute TimeSpan Object
Interval Hour To Second IntervalHourToSecond TimeSpan Object
Interval Minute IntervalMinute TimeSpan Object
Interval Minute To Second IntervalMinuteToSecond TimeSpan Object
Interval Second IntervalSecond TimeSpan Object
Interval Year IntervalYear String StringFixedLength
Interval Year To Month IntervalYearToMonth String StringFixedLength
Interval Month IntervalMonth String StringFixedLength
Period Data Types Period(Date) PeriodDate String String
Period(Time) PeriodTime String String
Period(Time With Time Zone) PeriodTimeWithZone String String
Period(Timestamp) PeriodTimestamp String String
Period(Timestamp With Time Zone) PeriodTimestampWithTimeZone String String
TD_ANYTYPE Data Types TD_ANYTYPE TdAnyType See note below object
Xml Xml Xml String
Char[]
Xml

Note

BOLD DbType Enumeration values in the table above show the primary mapping for DbType value to the SQL data type. The Data Provider will use the primary DbType mapping when TdParameter.DbType property is used to specify the Parameter Data Type.

Note

TdType Enumeration does not have a member corresponding to User Defined Types (UDT), User Defined Array Types, Geospatial Types or Dataset Avro. The SQL Engine transforms the aforementioned types to and from predefined SQL types.

Note

TD_ANYTYPE supports character and CLOB, byte and BLOB, numeric, date and time, and interval data types. See the BCL types for these supported data types.