gpt4 book ai didi

mysql - 驻留在 mysql 列中的字符串无法插入到 redshift 上完全相同的列中,指出 DDL 长度错误

转载 作者:行者123 更新时间:2023-11-29 07:35:59 26 4
gpt4 key购买 nike

我的理解是,进入 Mysql 字符串列 varchar(255) 的字符串理想情况下应该进入 varchar(255) 的 Redshift 列。 (utf8 字符集)

我被困在一个失败的用例中。

我有一个长度为 255 个字符的示例字符串,

'测试数据:美国标准时间 12-10-20 23:43 左右,由于发现卖家联系电话从 abc 中丢失,宣布了 ABC 事件。必填字段显示为空,屏幕上显示消息“Bad Response/err1 9 error in the comput”,也无法激活标志' => 长度 255

Mysql

CREATE TABLE `test_varchar255` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`token` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;


insert into test_varchar255 values (1, 'Test data: Around 23:43 IST on
12-10-20, a ABC event was announced due to seller contact number found
missing from abc. The required field is showing empty with message on
screen “Bad Response/err1 9 error in the comput”, and also unable to
activate signs')

插入成功

Redshift

CREATE TABLE test_varchar255 (
id BIGINT DEFAULT NULL encode mostly32,
string_01 VARCHAR(255) DEFAULT NULL ENCODE LZO
)


insert into test_varchar255 values (1, 'Test data: Around 23:43 IST on
12-10-20, a ABC event was announced due to seller contact number found
missing from abc. The required field is showing empty with message on
screen “Bad Response/err1 9 error in the comput”, and also unable to
activate signs')

错误:对于类型字符变化的值太长 (255)查询失败PostgreSQL 说:对于类型字符 varying(255) 值太长

试图找出确切的问题,有什么帮助吗?

最佳答案

varchar(255) 表示您有一个可变长度的字符串,最大长度为 255。然而,重要的是要注意,如果有一种编码,一个字符使用 3 个字节(如 utf8),那么你有 256 * 3 = 768 个字节。如果您的另一列将字符编码为两个字节,那么它最多可以存储 256 * 2 = 512 字节,因此,您尝试将 768 字节大小的字符串存储到最大大小为 512 字节的位置.所以,你所经历的只是症状。

有效问题的性质取决于您的实际情况。如果需要显示LZO无法表示的字符,则更改目标表的编码。如果没有这样的字符,那么在尝试存储之前,请确保您的字符串在 LZO 中得到了很好的表示。

关于mysql - 驻留在 mysql 列中的字符串无法插入到 redshift 上完全相同的列中,指出 DDL 长度错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48865180/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com