15.10 - INTERVAL SECOND Data Type - Teradata Database

Teradata Database SQL Data Types and Literals

prodname
Teradata Database
vrm_release
15.10
category
Programming Reference
featnum
B035-1143-151K

Identifies a field as an INTERVAL value defining a period of time in seconds.

where:

 

Syntax element …

Specifies …

precision

the permitted range of digits for SECOND, ranging from one to four.

The default is two.

fractional_seconds_precision

the fractional precision for the values of SECOND, ranging from zero to six.

The default is six.

attributes

appropriate data type, column storage, or column constraint attributes.

See “Core Data Type Attributes” on page 17 and “Storage and Constraint Attributes” on page 18 for specific information.

INTERVAL SECOND is ANSI SQL:2011 compliant.

Conceptually, the internal representation of INTERVAL SECOND consists of the following fields.

 

Field Name

Storage Format

Total Length

WHOLE SECONDS

SMALLINT

6 bytes

FRACTIONAL SECONDS

INTEGER

INTERVAL SECOND types are imported and exported in record and indicator modes as CHARACTER data using the client character set.

 

WHEN fractional_seconds_precision is …

THEN the type and format are...

0

Type:

CHARACTER(precision + 1)

Format:

'-s(precision)'

n

where n is 1 - 6

Type:

CHARACTER(precision + n + 2)

Format:

'-s(precision).s(n)'

For example, for INTERVAL SECOND(3,2), the value might be something like '-127.35'.

The range of values for INTERVAL SECOND is as follows.

 

Type, Precision, and
Fractional Seconds Precision

Minimum Value

Maximum Value

INTERVAL SECOND(1,0)

-'9'

'9'

INTERVAL SECOND(1,1)

-'9.9'

'9.9'

INTERVAL SECOND(1,2)

-'9.99'

'9.99'

INTERVAL SECOND(1,3)

-'9.999'

'9.999'

INTERVAL SECOND(1,4)

-'9.9999'

'9.9999'

INTERVAL SECOND(1,5)

-'9.99999'

'9.99999'

INTERVAL SECOND(1,6)

-'9.999999'

'9.999999'

INTERVAL SECOND(2,0)

-'99'

'99'

INTERVAL SECOND(2,1)

-'99.9'

'99.9'

INTERVAL SECOND(2,2)

-'99.99'

'99.99'

INTERVAL SECOND(2,3)

-'99.999'

'99.999'

INTERVAL SECOND(2,4)

-'99.9999'

'99.9999'

INTERVAL SECOND(2,5)

-'99.99999'

'99.99999'

INTERVAL SECOND(2,6)

-'99.999999'

'99.999999'

INTERVAL SECOND(3,0)

-'999'

'999'

INTERVAL SECOND(3,1)

-'999.9'

'999.9'

INTERVAL SECOND(3,2)

-'999.99'

'999.99'

INTERVAL SECOND(3,3)

-'999.999'

'999.999'

INTERVAL SECOND(3,4)

-'999.9999'

'999.9999'

INTERVAL SECOND(3,5)

-'999.99999'

'999.99999'

INTERVAL SECOND(3,6)

-'999.999999'

'999.999999'

INTERVAL SECOND(4,0)

-'9999'

'9999'

INTERVAL SECOND(4,1)

-'9999.9'

'9999.9'

INTERVAL SECOND(4,2)

-'9999.99'

'9999.99'

INTERVAL SECOND(4,3)

-'9999.999'

'9999.999'

INTERVAL SECOND(4,4)

-'9999.9999'

'9999.9999'

INTERVAL SECOND(4,5)

-'9999.99999'

'9999.99999'

INTERVAL SECOND(4,6)

-'9999.999999'

'9999.999999'

Teradata Database performs implicit conversion from one Interval data type to another Interval type in some cases. You can also use CAST to explicitly convert one Interval type to another.

Conversions are possible only within the same INTERVAL family. For example, you may convert a YEAR interval to months, but not to days or hours.

For more information, see “Data Type Conversions” in SQL Functions, Operators, Expressions, and Predicates.

The following statement creates a table with an INTERVAL SECOND column:

   CREATE TABLE TimeInfo 
     (Id INTEGER
     ,Offset INTERVAL SECOND (2,3));
   
   INSERT TimeInfo (1001, INTERVAL -'15.244' SECOND);