【问题标题】:Covert an integer to binary in netezza sql在netezza sql中将整数转换为二进制
【发布时间】:2017-01-24 22:59:40
【问题描述】:

我正在尝试将整数转换为二进制。这是我的代码

create table test
(test varbinary(8));

insert into test 
select int_to_string(7, binary) as test;

这是我得到的错误:

错误 [HY000] 错误:必须为可变二进制属性指定大小。

【问题讨论】:

  • 我认为您需要在select int_to_string(7, binary) 中指定base 2 而不是binary

标签: sql netezza


【解决方案1】:
  1. per the answer proposed by ScottMcG to user3206440's related question 我认为最好使用 varchar(8) 来存储数据,而不是 varbinary。
  2. 根据@rajat-mishra 的提示,您的insert 语句应该是:

    insert into test select int_to_string(7, 2) as test;

【讨论】:

    猜你喜欢
    • 2015-12-15
    • 2016-07-28
    • 1970-01-01
    • 2012-04-10
    • 2021-11-03
    • 2012-05-11
    • 2015-09-21
    • 2017-10-29
    相关资源
    最近更新 更多