- 类别:
半结构化和结构化数据函数 (类型转换)
AS_BINARY¶
将 VARIANT 值转换为二进制字符串。
- 另请参阅:
语法¶
AS_BINARY( <variant_expr> )
实参¶
variant_expr
VARIANT 类型值计算的表达式。
示例¶
这显示了该函数的使用方法:
创建表和数据:
CREATE TABLE multiple_types ( binary1 VARIANT, date1 VARIANT, decimal1 VARIANT, time1 VARIANT, timestamp1 VARIANT ); INSERT INTO multiple_types (binary1, date1, decimal1, time1, timestamp1) SELECT TO_VARIANT(TO_BINARY('F0A5')), TO_VARIANT(TO_DATE('2018-10-10')), TO_VARIANT(TO_DECIMAL(1.23, 6, 3)), TO_VARIANT(TO_TIME('12:34:56')), TO_VARIANT(TO_TIMESTAMP_NTZ('2018-10-10 12:34:56')) ;现在运行查询:
SELECT AS_BINARY(binary1) AS "Binary" FROM multiple_types;输出:
+--------+ | Binary | |--------| | F0A5 | +--------+