You are on page 1of 4

DATA TYPES Every column in a table has a name and data type.

The data type tells Teradata how much physical storage to set aside for the column, as well as the form in which to store the data. Teradata data types fall into categories: binary, character, date, and numeric data. Char data
There are two data types for holding character data: CHAR - has fixed-length character strings. VARCHAR - has variable-length character strings.

In both cases, the maximum string length is 64,000 characters. String size is specified in parentheses after the keyword CHAR or VARCHAR as in CHAR(20) or VARCHAR(20). In the case of CHAR, if you insert a character string less than the specified size (20 in the above example), the system will append and store trailing blanks as needed to expand the string to the specified length. The size specified on a VARCHAR field represents a maximum length. The system will not pad the contents with trailing blanks. (It will use two extra bytes to store the length internally) Example: Create table employee ( emp_id int, emp_no int, first_name char(20), last_name varchar(20) emp_add varchar (50), dob date format (dd-mm-yyyy) ); In this query we give firstname as hari,Actually it needs only 4 bytes.But the char datatype uses all 20 bytes.In the sense varchar we give the name it occupies only 4

bytes. VARCHAR makes more efficient use of the space, because it does not pad values with trailing blanks. LONG VARCHAR is equivalent to a maximum VARCHAR BYTE DATA Teradata supports two data types for holding binary data: BYTE. VARBYTE. BYTE is for fixed length binary strings. Default: (1) Max: 64,000 bytes VARBYTE is for variable length binary strings. These data types are used for storing binary objects such as digital images, executable objects, flat files,etc. Variable length Binary string Default: (1) Max: 64,000 bytes. NUMERIC DATA

Data Type BYTEINT*

Description Whole number Range -128 to 127 Storage: 1 byte Whole number Range: -32,768 to 32,767 Storage: 2 bytes Whole number Range: -2,147,483,648 to 2,147,483,647 Storage: 4 bytes

Examples basket_count BYTEINT +125

SMALLINT

area_code SMALLINT +00213 (up to 5 digits)

INTEGER

phone INTEGER +0006495252 (up to 10 digits)

BIGINT

Whole number international_phone BIGINT Range +0000010807934842145 (up to 19 digits) 9,233,372,036,854,775,807 Storage: 8 bytes

DEC(m, n) DECIMAL(m,n) NUMERIC(m,n) (Small Decimal)

'm' is total number of digits. salary_amount DEC (10,2) (m <= 18) +00035000.00 'n' is precision places to the right of decimal point. Max Size =18 digits Storage: 2 to 8 bytes 'm' is total number of digits. sheet_thickness DEC (32,30) (18 < m <= 38) +01.123498782792787582977278497827 'n' is precision places to the right of decimal point. Max Size = 38 digits Storage: 16 bytes Floating Point Format (IEEE) salary_factor FLOAT 2x10-307 to 2x10+308 +4.35400000000000E-001 Storage: 8 bytes Internally represented as FLOAT Internally represented as FLOAT Internally represented as FLOAT

DEC(m, n) DECIMAL(m,n) NUMERIC(m,n) (Large Decimal)

FLOAT

FLOAT [(precision)] REAL

DOUBLE PRECISION

DATE DATATYPE EXAMPLE: Create table employee ( emp_id int, emp_no int, first_name char(20), last_name varchar(20) emp_add varchar (50),

birth_date date ); here we give the data datatype for the column birth_date.It takes the default date format and the default format is yy/mm/dd. We also specify the format for date datatype. For example Create table employee ( emp_id int, emp_no int, first_name char(20), last_name varchar(20) emp_add varchar (50), birth_date date format (dd-mm-yyyy) );

You might also like