String Types
Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API
Data 360 SQL supports three string types.
| Name | Description |
|---|---|
text | A string of variable length |
character varying(n), varchar(n) | A string with a limited variable length |
character(n), char(n) | A string with a fixed length. Padding is added if the string doesn’t fill the fixed length. |
The text type stores strings of any length up to 2 GB.
SQL defines two primary character types: character varying(n) and character(n), where n is a positive integer. Both of these types can store strings up to n characters in length. An attempt to store a longer string results in only the first n characters being stored. If the string to be stored is shorter than the declared length, values of the type character are padded. Character type character varying stores shorter string without padding.
If you don’t provide a length specifier, character is equivalent to character(1) and character varying accepts strings with a length of up to 2 GB.
Data 360 SQL internally stores all string as UTF-8, and there are no character set considerations.
The table test1 is defined as:
| a |
|---|
| ok |
| good |
| just perfect |
Results:
| a | char_length |
|---|---|
| ok | 2 |
| good | 4 |
| just perfect | 12 |
The table test1 has one column with values defined as character(4):
| a |
|---|
| ok |
Output:
| a | char_length |
|---|---|
| ok | 2 |
The table test1 has one column with values defined as varchar(5):
| b |
|---|
| 'ok' |
| 'good ' |
| 'too long' |
Output:
| b | char_length |
|---|---|
| ok | 2 |
| good | 5 |
| too l | 5 |