The result of a concatenation operation is a string formed by concatenating the arguments in a left-to-right direction.
Here are the default result type and attributes for arg1 || arg2:
- If the arguments are byte strings, the result is a byte string.
- If the arguments are numeric or character strings that are implicitly cast to character strings, the result is a character string.
If either argument is null, the result is null.
The data types and attributes of the arguments determine whether the result type of a concatenation operation is a fixed length or varying length string. Result types appear in the following table, where n is the sum of the lengths of all arguments:
| Argument | Argument Data Type or Attribute | Result Data Type or Attribute |
|---|---|---|
| Either | VARBYTE | VARBYTE(n) |
| VARCHAR | VARCHAR(n) | |
| numeric | ||
| CLOB | CLOB(n) | |
| BLOB | BLOB(n) | |
| Both | BYTE | BYTE(n) |
| CHARACTER (with same server character set) | CHARACTER(n) | |
| CHARACTER (with different server character sets) | VARCHAR(n) | |
| numeric |
When either argument is a character string that specifies the CASESPECIFIC attribute, the result also specifies the CASESPECIFIC attribute.