CHAR Data type
Description
The
CHAR
data type specifies a fixed-length character string in the database character set.(Oracle SQL Language Reference CHAR Data type)
As denoted in the Oracle documentation, size in CHAR data type is a length constraint and should not be confused with capacity. Total characters that can be stored in a CHAR may vary according to the database character set and configuration, but commonly the maximum size allowed is 2000.
In Snowflake, CHAR types are synonymous with VARCHAR, and as you can check here:
Snowflake SQL Language reference text data types
The standard maximum size is quite bigger. But, this doesn’t mean that a Snowflake VARCHAR will consume more storage, as mentioned in their documentation:
A 1-character string in a VARCHAR(16777216) column only consumes a single character.
Sample Source Patterns
Char data types in Create Table
Oracle
Snowflake
Retrieving data from char columns
Oracle
Snowflake
In Oracle, the value is filled with empty spaces to fit the fixed size determined in the column definition. On the other hand, Snowflakes uses dynamic size (keeping the length restriction) to store the value.
Checking internal data types for CHAR
As mentioned in the beginning, Snowflake internally uses a VARCHAR for the CHAR type columns, we can confirm it by describing the tables:
Oracle
Snowflake
The length restriction is preserved, but the memory that the columns are using is different on each DBMS.
Retrieving the size in bytes of each column:
Oracle
Snowflake
Besides these slight differences, the integrity of the data is preserved.
Known Issues
1. Results obtained from some built-in functions may vary
As explained in the previous section, there may be cases using built-in functions over the columns that may retrieve different results. For example, get the length of a column.
Related EWIs
SSC-FDM-OR0015: LENGTHB transformed to OCTET_LENGTH.
Last updated