This document provides an overview of data types, arithmetic operators, functions, and data conversions in Teradata:
- It defines common data types like character, numeric, date/time and examples of each. Character types include VARCHAR and CHAR, numeric types include INTEGER, DECIMAL, and DATE.
- Arithmetic operators like addition, subtraction, multiplication and division are covered. Teradata also supports exponentiation and modulo functions.
- Common numeric, date, and conversion functions are listed such as ABS, EXP, LOG, EXTRACT and CAST.
- Methods for converting between data types using CAST and implicit conversion are shown.
Abortion Clinic in Randfontein +27791653574 Randfontein WhatsApp Abortion Cli...
2.1 Data types.pdf
1. Data Converstions and Computations
After completing this module, you will be able to:
• Define the data type for a column in a table
• Compute values using arithmetic functions and operators
• Convert from one data type to another
• Manipulate the DATE data type
2. Data Types – Character Data
Equivalent to
VARCHAR(64000)
LONG VARCHAR
Address
VARCHAR(50)
Variable Length string
Max : 64,000 Charecters
VARCHAR(size)
CHAR
VARYING(Size)
CHARACTER
VARYING(Size)
Name
CHAR(20)
Fixed Length string
Max : 64,000 Charecters
CHAR(Size)
Example
Description
Character Data
3. Data Types – Byte Data
• Never translated by the Teradata RDBMS
•Suitable for digitized image information
Variable Length Binary
string
Max : 64,000 bytes
VARBYTE(size)
Fixed Length Binary string
Max : 64,000 bytes
BYTE(Size)
Description
BYTE Data
4. Data Types – Character Data
Internally represented as FLOAT
FLOAT[(Precision)],
DOUBLE PRECISION , REAL
Floating point Format(IEEE)
2x10-307 TO 2x10-308
FLOAT
Synonym for DECIMAL
NUMERIC[(<precision>)],
[,<scale>])]
Decimal number
Max : 18 digits
DECIMAL(size,Dec)
Whole Number –2147483648 to
2147483647
INTEGER
Whole Number –128 to 127
BYTEINT
Whole Number -32768 to 32767
SMALLINT
Description
Numeric Data
5. Data Types – Date/Time
YYMMDD HHMMSS.nnnnnn + HHMM
TIMESTAMP) WITH Z
HHMMSS.nnnnnn + HHMM
TIME) WITH ZONE
YYMMDD HHMMSS.nnnnnn
TIMESTAMP
HHMMSS.nnnnnn
TIME
Represented as INTEGER
(YEAR –1900) * 10000 + (MONTH *100) + DAY
DATE
Description
Numeric Data
7. Functions
Numeric Functions
Absolute value
Raises e to the power of <arg>
Base 10 logarithm
Natural logorithm
Square root
ABS
EXP
LOG
LN
SQRT
Meaning
Function
DATE functions
EXTRACT(YEAR FROM DATE)
EXTRACT (MONTH FROM DATE)
EXTRACT(DAY FROM DATE)
ADD_MONTHS(DATE, n)
Function
8. Data Conversion
• To Convert an expression from one data type to another
Select CAST( name AS
CHAR(10)
UPPERCASE ) From
emp;
CAST<expr> as <Data
type> <data attribute>
Select name
(CHAR(10)) From emp;
<expr> (<type>)
CAST<expr> as <Data
type>
EXAMPLE
TERADATA
ANSI