Chapter 1. Data Types

Table of Contents

1.1. Overview
1.2. String
1.3. Number
1.4. Datetime
1.5. Interval
1.6. Binary
1.7. Embedded

This chapter introduces the default data types provided in Tibero and describes their usage.

1.1. Overview

Data type is used when a schema object is created for a database. General client programs can use variables that corresponds to all data types.

Data types provided in Tibero are:

ClassificationData TypeDescription
String typeCHAR, VARCHAR, VARCHAR2, NCHAR, NVARCHAR, CLOB, NCLOB, LONG, XMLTYPEStrings.
Numeric typeNUMBER, BINARY_FLOAT, BINARY_DOUBLEIntegers or real numbers.
Datetime type

DATE, TIME, TIMESTAMP,

TIMESTAMP WITH TIME ZONE,

TIMESTAMP WITH LOCAL TIME ZONE

Times and/or dates.
Interval type

INTERVAL YEAR TO MONTH,

INTERVAL DAY TO SECOND

Time intervals.
Binary typeRAW, BLOB, LONG RAWBinary data.
Embedded typeROWIDColumn type that Tibero automatically inserts in every row before being declared.

Note

For more information about data types, refer to Tibero SQL Reference Guide.

1.2. String

The following describes how to use string data types.

CHAR

The CHAR type stores fixed-length character strings.

Used in the following way:

CHAR[(size[BYTE|CHAR])]
OptionDescription
size

The size option can be set. (Maximum: 2,000 bytes)

  • If set, the data length is the byte length of the data.

  • If not set, the data length will be 1 byte by default.

VARCHAR, VARCHAR2

The VARCHAR and VARCHAR2 types store variable-length character strings.

Used in the following way:

VARCHAR(size[BYTE|CHAR])
VARCHAR2(size[BYTE|CHAR])
OptionDescription
sizeThe data length is the byte length of the data. (Maximum: 65,532 bytes)

NCHAR

The NCHAR type stores fixed-length character strings that use the national character set.

Used in the following way:

NCHAR(size)
OptionDescription
sizeThe data length is the byte length of the data. (Maximum: 2,000 bytes)

NVARCHAR

The NVARCHAR type stores variable-length character strings that use the national character set.

Used in the following way:

NVARCHAR(size)
OptionDescription
sizeThe data length is the byte length of the data. (Maximum: 4,000 bytes)

CLOB

The CLOB type stores a large amount of readable strings.

Used in the following way:

CLOB

The maximum data size is 4GB.

NCLOB

The NCLOB type stores a large amount of readable strings that use the national character set.

Used in the following way:

NCLOB

The maximum data size is 4GB.

LONG

The LONG type stores a large amount of strings. This type is supported only for compatibility with Oracle. The CLOB type is recommended for all other purposes.

Used in the following way:

LONG

1.3. Number

The following describes how to use number data types.

NUMBER

The NUMBER type stores variable-length integers or real numbers.

Used in the following way:

NUMBER[(precision[, scale])]
OptionDescription
precisionTotal number of digits.
scaleThe number of digits to the right of the decimal point.

1.4. Datetime

The following describes how to use datetime data types.

DATE

The DATE type stores fixed-length strings of year, month, and date.

Used in the following way:

DATE

TIME

The TIME type stores fixed-length strings of hour, minute, and second.

Used in the following way:

TIME

TIMESTAMP

The TIMESTAMP type is an expanded type of the DATE type. This type stores a fixed-length string of year, month, date, and time.

Used in the following way:

TIMESTAMP[(fractional_seconds_precision)]
OptionDescription
fractional_seconds_precision

Fractional seconds precision.

  • A number between 0 and 9 can be used. (Default value: 6)

TIMESTAMP WITH TIME ZONE

The TIMESTAMP WITH TIME ZONE type is an expanded type of the TIMESTAMP type. This type converts a given time to UTC (Coordinated Universal Time) time format, and stores a fixed-length string made of year, month, date, and time.

Used in the following way:

TIMESTAMP[(fractional_seconds_precision)] WITH TIME ZONE
OptionDescription
fractional_seconds_precision

Fractional seconds precision.

  • A number between 0 and 9 can be used. (Default value: 6)

TIMESTAMP WITH LOCAL TIME ZONE

The TIMESTAMP WITH LOCAL TIME ZONE type converts a given time to a time in UTC time like TIMESTAMP WITH TIME ZONE, and stores a fixed-length string made of year, month, and date. This type has the same length as TIMESTAMP.

Used in the following way:

TIMESTAMP[(fractional_seconds_precision)] WITH LOCAL TIME ZONE
OptionDescription
fractional_seconds_precision

Fractional seconds precision.

  • A number between 0 and 9 can be used. (Default value: 6)

1.5. Interval

The following describes how to use interval data types.

INTERVAL YEAR TO MONTH

The INTERVAL YEAR TO MONTH type stores a fixed-length time interval of year and month.

Used in the following way:

INTERVAL YEAR [(year_precision)] TO MONTH
OptionDescription
year_precision

Year precision.

  • A number between 0 and 9 can be used. (Default value: 2)

  • Limits the number of digits of an interval year.

INTERVAL DAY TO SECOND

The INTERVAL DAY TO SECOND type stores a fixed-length time interval of day and time.

Used in the following way:

INTERVAL DAY [(day_precision)] TO SECOND [(fractional_seconds_precision)]
OptionDescription
day_precision

Day precision.

  • A number between 0 and 9 can be used. (Default value: 2)

fractional_seconds_precisionSame as the fractional_seconds_precision option of the TIMESTAMP type.

Note

This type can limit the number of digits stored for date and fractional second using day_precision and fractional_seconds_precision.

1.6. Binary

The following describes how to use binary data types.

RAW

The RAW type stores variable-length binary data.

Used in the following way:

RAW(size)
OptionDescription
sizeThe data length is the byte length of the data. (Maximum: 2,000 bytes)

BLOB

The BLOB type stores a large amount of binary data.

Used in the following way:

BLOB 

The maximum data size is 4GB.

LONG RAW

The LONG RAW type stores a large amount of binary data. This type is supported only for compatibility with Oracle. The BLOB type is recommended for all other purposes.

Used in the following way:

LONG RAW

1.7. Embedded

The following describes embedded data types, which are automatically included in each row by Tibero even though not declared explicitly.

ROWID

The ROWID type stores fixed-length row addresses of a database table.

Used in the following way:

ROWID