从整数到文本排序规则的 CAST 是特定的吗?
Is CAST from integer to text collation specific?
如果我将 integer
转换为 cast(phone as text)
之类的字符串类型,理论上是否有可能生成的字符串可能因数据库的排序规则而异?
换句话说,结果是否取决于添加的 COLLATE
子句(尤其是整数):
select cast(q as text) COLLATE "somecollation";
不,COLLATION
与从 int
到 text
的转换没有任何关系。结果 value 始终相同。
COLLATION
确实会影响相同的 text
值稍后在正则表达式中的排序或处理方式。如果将 COLLATE
子句附加到强制转换(或返回字符串类型的 any 表达式),排序规则将坚持该值,直到赋值或下一个表达式可能更改它。
The collation feature allows specifying the sort order and character classification behavior of data per-column, or even per-operation [...]
如果我将 integer
转换为 cast(phone as text)
之类的字符串类型,理论上是否有可能生成的字符串可能因数据库的排序规则而异?
换句话说,结果是否取决于添加的 COLLATE
子句(尤其是整数):
select cast(q as text) COLLATE "somecollation";
不,COLLATION
与从 int
到 text
的转换没有任何关系。结果 value 始终相同。
COLLATION
确实会影响相同的 text
值稍后在正则表达式中的排序或处理方式。如果将 COLLATE
子句附加到强制转换(或返回字符串类型的 any 表达式),排序规则将坚持该值,直到赋值或下一个表达式可能更改它。
The collation feature allows specifying the sort order and character classification behavior of data per-column, or even per-operation [...]