Hitachi

Hitachi Advanced Database SQL Reference


7.26.2 Data types of the results of concatenation operations

The data type of the result of a concatenation operation is determined by the data types of the first and second operands.

Organization of this subsection

(1) When the operands are character string data

The following table shows the relationship between the data types of the operands and the data type of the result of the operation when the operands are character string data.

Table 7‒36: Relationship between the data types of the operands and the data type of the result of the operation (when the operands are character string data)

No.

Data type and data length of the first operand

Data type and data length of the second operand

Data type and data length of the result of the operation

1

CHAR(m)

CHAR(n)

CHAR(m+n)

2

VARCHAR(n)

Actual data length: L2

VARCHAR(m+n)

Actual data length: m+L2

3

VARCHAR(m)

Actual data length: L1

CHAR(n)

VARCHAR(m+n)

Actual data length: L1+n

4

VARCHAR(n)

Actual data length: L2

VARCHAR(m+n)

Actual data length: L1+L2

Legend:

m: Maximum length of the data in the first operand

n: Maximum length of the data in the second operand

L1: Actual data length of the data in the first operand

L2: Actual data length of the data in the second operand

(2) When the operands are binary data

The following table shows the relationship between the data types of the operands and the data type of the result of the operation when the operands are binary data.

Table 7‒37: Relationship between the data types of the operands and the data type of the result of the operation (when the operands are binary data)

No.

Data type and data length of the first operand

Data type and data length of the second operand

Data type and data length of the result of the operation

1

BINARY(m)

BINARY(n)

BINARY(m+n)

2

VARBINARY(n)

Actual data length: L2

VARBINARY(m+n)

Actual data length: m+L2

3

VARBINARY(m)

Actual data length: L1

BINARY(n)

VARBINARY(m+n)

Actual data length: L1+n

4

VARBINARY(n)

Actual data length: L2

VARBINARY(m+n)

Actual data length: L1+L2

Legend:

m: Maximum length of the data in the first operand

n: Maximum length of the data in the second operand

L1: Actual data length of the data in the first operand

L2: Actual data length of the data in the second operand