DB2 VARCHAR unicode 数据存储
我们目前在 DB2 中使用 VARCHAR 来存储文本数据,但是我们遇到了一个问题,即指定的 VARCHAR 长度与文本长度不同,因为在 DB2 中指定的 VARCHAR 长度是 UTF-8 数据长度,该长度可能会根据存储的文本数据而变化。例如,某些文本包含来自不同语言的字符,因此某些 500 个字符的文本无法保存在 VARCHAR(500) 等中。
现在我们计划迁移到 VARGRAPHIC。我需要知道使用 VARGRAPHIC 在 DB2 中存储 unicode 文本数据有哪些限制。 使用VARGRAPHIC有什么问题吗?
We are currently using VARCHAR for storing text data in DB2 however we are hitting the problem that length of VARCHAR specified is not the same as length of text because in DB2 VARCHAR length specified is UTF-8 data length which can vary depending on stored text data. For example some texts contain characters from different languages and because of it some texts with 500 characters can't be saved in VARCHAR(500) and etc.
Now we are planning to migrate to VARGRAPHIC. I need to know what are limitations of using VARGRAPHIC for storing unicode text data in DB2.
Are there any problems with using VARGRAPHIC?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DB2 不会检查数据实际上是否是双字节字符串,但它假设它必须是。通常驱动程序会为您进行适当的转换,但有一天您可能会遇到一些错误。但这不太可能。
如果您使用联合数据库,查询中的 Vargraphic 支持可能会完全失败。总的来说,可变图形数据类型的错误报告数量有点高。对它的支持可能没有像其他数据类型那样经过充分的测试和尝试。
Vargraphic 将与 unicode 数据库(即需要 UTF-8)一起使用大端 UCS-2,这意味着这些列的空间需求加倍。 Vargraphic 是 DB2 专有数据类型。如果有一天您要从 DB2 迁移,您将需要进行额外的转换。
DB2 doesn't check that the data is in fact double-byte String, but it assumes it must be. Usually the drivers will do proper conversions for you but you might one day bump into some bug. It is unlikely though.
If you use federated databases Vargraphic support in queries might fail completely. In overall the amount of bug reports for vargraphic data types is somewhat high. Support for it isn't probably as well tested and tried as for other data types.
Vargraphic will with unicode database (ie. UTF-8 is requirement) use big-endian UCS-2, meaning your space requirements for those columns double. Vargraphic is DB2 properietary data type. If you migrate off DB2 some day you will have to do an extra conversion.