Snowflake 数据库 VARCHAR 列的度量单位是什么?
What is the unit of measure of a Snowflake database VARCHAR column?
在Snowflake数据库数据定义语言中,指定VARCHAR(10)
列时,长度“10”的计量单位是什么?是字节数还是字符数?
也就是说,如果我想存储一个4字节的字符,我需要指定VARCHAR(1)
还是VARCHAR(4)
?
我正在查看此处的文档,https://docs.snowflake.net/manuals/sql-reference/data-types-text.html,我明白了
The maximum number of Unicode characters that can be stored in a VARCHAR column depends on whether the characters are singlebyte or multibyte:
和
If a length is not specified, the default is the maximum length.
和
Snowflake currently deviates from common CHAR semantics in that strings shorter than the maximum length are not space-padded at the end.
但是,我仍然不确定长度说明符的度量单位是什么。
它是字符,而不是字节或代码点。这是一个简单的例子:
create table t (x varchar(1)) as select '123' AS x;
String '123' is too long and would be truncated
对战:
create or replace table t (x varchar(1)) as select '' AS x;
Table T successfully created.
笑脸Unicode字符为U+1F60A
,多了一个字节
在Snowflake数据库数据定义语言中,指定VARCHAR(10)
列时,长度“10”的计量单位是什么?是字节数还是字符数?
也就是说,如果我想存储一个4字节的字符,我需要指定VARCHAR(1)
还是VARCHAR(4)
?
我正在查看此处的文档,https://docs.snowflake.net/manuals/sql-reference/data-types-text.html,我明白了
The maximum number of Unicode characters that can be stored in a VARCHAR column depends on whether the characters are singlebyte or multibyte:
和
If a length is not specified, the default is the maximum length.
和
Snowflake currently deviates from common CHAR semantics in that strings shorter than the maximum length are not space-padded at the end.
但是,我仍然不确定长度说明符的度量单位是什么。
它是字符,而不是字节或代码点。这是一个简单的例子:
create table t (x varchar(1)) as select '123' AS x;
String '123' is too long and would be truncated
对战:
create or replace table t (x varchar(1)) as select '' AS x;
Table T successfully created.
笑脸Unicode字符为U+1F60A
,多了一个字节