7.27.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) If the data type of the operand is character string data
The following table shows the relationship between the data type of the operands and the data type of the result of the operation (if the data type of the operand is character string data).
|
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 operation result |
|---|---|---|
|
CHAR(m) |
CHAR(n) |
CHAR(m+n) |
|
VARCHAR(n) Data length: L2 |
|
|
|
STRING Data length: L2 |
STRING Actual data length: m + L2 |
|
|
VARCHAR(m) Actual data length: L1 |
CHAR(n) |
|
|
VARCHAR(n) Data length: L2 |
|
|
|
STRING Data length: L2 |
STRING Actual data length: L1 + L2 |
|
|
STRING Actual data length: L1 |
CHAR(n) |
STRING Actual data length: L1 + n |
|
VARCHAR(n) Data length: L2 |
STRING Actual data length: L1 + L2 |
|
|
STRING Data length: L2 |
STRING Actual data length: L1 + L2 |
- Legend:
-
m: Maximum data length of the first operand
n: Maximum data length of the second operand
L1: Actual data length of the data of the first operand
L2: Actual data length of the data of 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.
|
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