PERIOD(TIME) Data Type

Teradata Vantageā„¢ Data Types and Literals

brand
Software
Teradata Vantage
prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1143-162K

Purpose

A data type that has two DateTime elements associated with it.

The DateTime element... Specifies...
beginning the beginning bound of a period.
ending the ending bound of a period.

The beginning bound is inclusive, and the ending bound is exclusive; that is, the DateTime range starts at the beginning bound and extends up to but not including the ending bound.

A PERIOD(TIME[(n)]) column records the beginning and ending bounds in UTC form in the same manner as exists currently for a TIME column.

Syntax



fractional_seconds_precision
A single digit representing the number of significant digits in the fractional portion of the SECOND field.
Values for fractional_seconds_precision range from 0 to 6 inclusive.
The default precision is 6.
attributes
Appropriate data type, column storage, or column constraint attributes. See Core Data Type Attributes and Storage and Constraint Attributes for specific information.
The following data type attributes are supported for a PERIOD(TIME) column:
  • NULL and NOT NULL
  • FORMAT 'format string'
  • TITLE
  • NAMED
  • DEFAULT NULL
  • DEFAULT value
For details on these data type attributes, see Default Value Control Phrases and Data Type Formats and Format Phrases.
The following data type attributes are not supported for a PERIOD(TIME) column:
  • DEFAULT USER
  • DEFAULT DATE
  • DEFAULT TIME
  • DEFAULT CURRENT_DATE
  • DEFAULT CURRENT_TIME[(n)]
  • DEFAULT CURRENT_TIMESTAMP[(n)]
  • UPPERCASE or UC
  • CASESPECIFIC or CS
  • CHARACTER SET
  • WITH DEFAULT

ANSI Compliance

Period types are a Teradata extension to the ANSI SQL:2011 standard.

Storage

A PERIOD(TIME[(n)]) is a fixed length data type and is saved as two TIME values.

Element Type Field Size in bytes Maximum Size in bytes in the row
TIME(n) 12 16

External Representation of PERIOD(TIME)

In field mode, Teradata Database returns PERIOD(TIME) data as character data.

Assume L is the maximum length of the formatted character string for the format associated with this Period data type. The resulting character string contains two strings representing the beginning and ending bounds of the period value expression, each up to length L , and each enclosed in apostrophes ('), separated by comma and a space (,), and then enclosed within a left and right parenthesis [( )]. Thus, the maximum length of the resulting character string is 2* L +8.

For modes other than field mode, and for input data, the external representation of PERIOD(TIME) consists of two consecutive time values. Each time value consists of multiple fields as explained below and returned in the specified order:
  • Second: 4-byte, signed integer flipped to client form. This integer represents the number of seconds as a scaled decimal (for example, 12.56 seconds is returned as 12560000).
  • Hour: 1 unsigned byte. This byte represents the number of hours.
  • Minute: 1 unsigned byte. This byte represents the number of minutes.

Restrictions

A primary index column or partitioning column cannot be a column that has a Period data type.

Example: PERIOD(TIME) Data Type

The following CREATE TABLE statement defines a PERIOD(TIME(6)) column since the precision defaults to 6.

CREATE TABLE t8
(
      job_id        INTEGER,
      job_desc      CHARACTER(15),
      job_status    CHARACTER(1),
      job_hours     PERIOD(TIME));

Related Topics

For information on functions and operators that apply to Period types, see Teradata Vantageā„¢ SQL Functions, Expressions, and Predicates, B035-1145.