Appendix A Type and Format Differences Between Teradata and Other DBMS . Teradata 2580
Mainos
Mainos
APPENDIX A
Type and Format Differences
Between Teradata and Other DBMS
This appendix describes the differences between the types and formats used in Teradata and those used in other database management systems, such as Oracle.
Teradata Data Types
The data types supported in Teradata Database may differ from the data types in other ANSIcompliant databases. Therefore, you need to convert your data types to Teradata data types.
Be aware that even though some data types seem the same in both systems, there may be subtle differences in the way the data types are implemented. Therefore, your query may not return an error, but the results may not be as expected.
Recommendation: Always test your queries thoroughly after converting to Teradata and make sure that the data type functions as you expect.
The following table shows how some Oracle data types can be mapped to Teradata data types:
Oracle Data Type
BLOB/CLOB
CHAR
DATE
FLOAT
LONG
LONG RAW
NUMBER or NUMBER(38)
NUMBER(m, n)
VARCHAR2
Teradata Data Type
BLOB/CLOB
CHAR
DATE or TIMESTAMP(0)
FLOAT
(The total number of digits cannot exceed 15)
LONG VARCHAR or VARCHAR
VARBYTE (<=64000)
DECIMAL(38)
DECIMAL(m, n)
VARCHAR
Teradata Data Warehouse Appliance 2580 Implementation Guide 375
Appendix A: Type and Format Differences Between Teradata and Other DBMS
Teradata Data Types
In Teradata, the maximum number of characters or bytes allotted to a CHAR or VARCHAR column depends on the server character set for the column. For example, if the server character set is:
•
LATIN, then the maximum value is 64,000
•
UNICODE, then the maximum value is 32,000
For Oracle users, note that Oracle does not have an INTEGER data type, but they have an alias called INTEGER that maps to the NUMBER data type. NUMBER corresponds to the
DECIMAL data type in Teradata. Teradata has several additional numeric data types, including:
•
BYTEINT - a signed binary integer value from -128 to 127
•
SMALLINT - a signed binary integer value from -32,768 to 32,767
•
INTEGER - a signed, binary integer value from -2,147,483,648 to 2,147,483,647
•
BIGINT - a signed, binary integer value from -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807
The following table shows additional possibilities for converting the NUMBER data type.
Oracle Data Type
NUMBER(1)
NUMBER(2,n)
NUMBER(3)
NUMBER(4,n)
NUMBER(5)
NUMBER(9,n)
NUMBER(10)
NUMBER(18)
NUMBER(19,n)
NUMBER(38,n)
Teradata Data Type
BYTEINT - 8 bits or
DECIMAL(1) - 8 bits
DECIMAL(2,n) - 8 bits
BYTEINT - 8 bits or
SMALLINT - 16 bits or
DECIMAL(3) - 16 bits
DECIMAL(4,n) - 16 bits
SMALLINT - 16 bits or
INTEGER - 32 bits or
DECIMAL(5) - 32 bits
DECIMAL(9,n) - 32 bits
INTEGER - 32 bits or
DECIMAL(10) - 64 bits
BIGINT - 64 bits or
DECIMAL(18) - 64 bits
DECIMAL(19,n) - 128 bits
DECIMAL(38,n) - 128 bits
376 Teradata Data Warehouse Appliance 2580 Implementation Guide
Appendix A: Type and Format Differences Between Teradata and Other DBMS
Teradata Data Types
DATE Formats
In Teradata, the date format for the system is set with the DateForm configuration setting and the default date format setting in the specification for data formatting (SDF) file.
Those settings determine the following:
•
Export data type of DATE values
•
Data entry format for DATE values
•
Format of DATE values in macros being executed
•
Date format for string-to-DATE comparisons and conversions
•
Display format of DATE columns in newly created tables and views
You can use the DBS Control utility (dbscontrol) to set DateForm to the following:
Setting
0 (IntegerDate)
1 (ANSIDate)
Description
Use the system default DATE format specified in the SDF file.
The default format is YY/MM/DD. However, you can customize the SDF file to change this date format to any valid date format.
The export data type is four-byte integer.
The system default DATE format is YYYY-MM-DD.
The export data type is CHARACTER(10).
This format is similar to the DATE data type format in Oracle.
Initially, DateForm is set to IntegerDate. You can override the system-level date format for a user, session, individual DATE column or DATE value.
To change the DATE format setting for ...
the system the session a user a DATE column or DATE value
Use the ...
•
DBS Control utility to change the DateForm setting.
•
Locale Definition utility (tdlocaledef) to customize the SDF file.
SET SESSION DATEFORM statement.
DATEFORM option in the CREATE USER or
MODIFY USER statement.
FORMAT phrase.
To view the current value of the system default DATE format, enter:
HELP SESSION;
Recommendation: To avoid format errors in date operations, specify dates as ANSI DATE literals. All SQL date operations accept this format. The format for an ANSI DATE literal is:
DATE 'YYYY-MM-DD'
Teradata Data Warehouse Appliance 2580 Implementation Guide 377
Appendix A: Type and Format Differences Between Teradata and Other DBMS
Teradata Data Types
Geospatial Types
Teradata Database supports geospatial types. Geospatial information identifies the geographic location of features and boundaries on the planet. Geospatial types address the need to store, manage, retrieve, manipulate, and analyze geospatial information by governmental bodies and commercial enterprises. For example, local governments might use geospatial data for city planning, traffic management, or accident investigation.
You can use geospatial types to represent 0-dimensional (point), 1-dimensional (line), and 2dimensional (polygon) geometries.
Teradata Database implements geospatial types as system-defined structured types. The geospatial types define methods that perform geometric calculations and test for spatial relationships between two geospatial values.
User-Defined Types
Teradata Database supports user-defined types (UDTs). SQL provides a set of predefined data types, such as INTEGER and VARCHAR, that you can use to store the data that your application uses, but they might not satisfy all of the requirements you have to model your data.
User-defined types allow you to extend SQL by creating your own data types and then using them like predefined data types. You can also define methods that operate on the UDT.
Distinct Types
Distinct UDTs are based on a single predefined data type, such as INTEGER or VARCHAR.
For example, you can create a distinct UDT named euro that is based on a DECIMAL(8,2) data type and use it to store monetary data. You can define a method for the euro type that converts the value to a US dollar amount.
Structured Types
Structured UDTs are collections of one or more fields called attributes, each of which is defined as a predefined data type or other UDT (which allows nesting).
For example, you can create a structured UDT named circle that consists of x-coordinate, y-coordinate, and radius attributes. You can define a method for the circle type that computes the area of the circle using the radius attribute.
Note: Teradata has different storage definition requirements than Oracle and does not use extents or table spaces.
378 Teradata Data Warehouse Appliance 2580 Implementation Guide
Appendix A: Type and Format Differences Between Teradata and Other DBMS
Reference Information
Reference Information
Information on...
supported data types in Teradata Database, including UDTs geospatial types
DATE literals
DATE formats and the FORMAT phrase
Is available in...
Chapter 3: “Decimal/Numeric Data Types”SQL Data
Types and Literals
Chapter 2: “Types” in SQL Geospatial Types,
Publication number B035-1181-098A, available from http://www.info.teradata.com
.
“Date Literals”
in Chapter 2: “Data Literals”
SQL Data Types and Literals
Chapter 10: “Data Type Formats and Format
Phrases” using the DBS Control utility (dbscontrol) to change the DateForm setting
SQL Data Types and Literals
Chapter 12: “DBS Control (dbscontrol)” the SDF file and the Locale Definition utility (tdlocaledef)
Utilities: Volume 1 (A-K)
Chapter 2: “Locale Definition Utility (tdlocaledef)”
•
CREATE USER / MODIFY USER
•
HELP SESSION
•
SET SESSION DATEFORM
Utilities: Volume 2 (L-Z)
“CREATE USER”
in Chapter 6: “CREATE TRANSFORM - CREATE
VIEW”
SQL Data Definition Language Detailed Topics
Teradata Data Warehouse Appliance 2580 Implementation Guide 379
Appendix A: Type and Format Differences Between Teradata and Other DBMS
Reference Information
380 Teradata Data Warehouse Appliance 2580 Implementation Guide
Lataa
Mainos