首页 > 解决方案 > Redshift 创建一个带有静态字符串错误的新列

问题描述

我的查询是如何实现的我使用一个语句SELECT 'ChickenMongoose' as animal来创建一个带有静态单词“ChickenMongoose”的新列但是我从 redshift 中得到这个错误Value too long for type character varying(7)如何创建一个带有静态字符串的新列来适应这个长度?

更多上下文:

UNION ALL
(SELECT 'ChickenMongoose' as animal ,
       SUM(COALESCE(friends.touches, 0)) AS touches
       FROM
        basic t
       INNER JOIN
        mock_friends friends ON friends.initiative_id = t.initiative_id
       WHERE
       'ChickenMongoose' in ('ChickenMongoose', 'potato')

基本上我的查询与联合 ALLS 连接,顶部有一个 select 语句,它不允许我将 ChickenMongoose 分配为动物列下的静态名称

谢谢

标签: pythonmysqlsqlamazon-redshift

解决方案


在 Redshift 中,尝试将最后一行替换
'ChickenMongoose' in ('ChickenMongoose', 'potato')

animal in ('ChickenMongoose', 'potato')

因为它会将其视为非整数字符常量


推荐阅读