DB2 不保存风格化的撇号 (’)
我正在尝试将程式化的撇号 (') 插入到 DB2 LUW 9.7 中的表中。我尝试过的每种方法都导致它在选择回来时成为正方形()。
我尝试插入它的方法:
- 在控制中心 (GUI) 中修改和提交行
- 通过命令编辑器中的 SQL 命令更新
- 行 通过 IBM Data Studio 2.2 从文件(UTF-8 编码和 ANSI 编码)加载
是否存在有办法把这个字符存入数据库吗?如果没有,是否有一个根本不能使用的字符列表?
I am trying to insert a stylized apostrophe (’) into a table in DB2 LUW 9.7. Every method I have tried has resulted in it being a square () when selected back.
The methods I have tried to insert it:
- Modifying and committing a row in Control Center (GUI)
- Updating a row via SQL command in Command Editor
- Loading from a file (both UTF-8 encoded and ANSI encoded) through IBM Data Studio 2.2
Is there a way to get this character into the database? If not, is there a list of characters that simply cannot be used?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的数据库/表空间的编码是什么?我怀疑它需要设置为UTF-8。您可能需要创建一个新的表空间或重新创建数据库,并将编码显式设置为 UTF-8。
至 确定编码,运行以下命令并查找“Code set”信息:
What is the encoding of your database/tablespace? I suspect it needs to be set to UTF-8. You may need to create a new tablespace or recreate the database with the encoding explicitly set to UTF-8.
To determine the encoding, run the following command and look for the "Code set" information:
来自在 DB2 表中插入撇号
参见:
http://www.ibmmainframes.com/viewtopic.php?t=36901& ;highlight=撇号 和
http://www.ibmmainframes.com/viewtopic.php?t=29213& ;突出显示=撇号
from Inserting an Apostrophe in DB2 table
see also:
http://www.ibmmainframes.com/viewtopic.php?t=36901&highlight=apostrophe and
http://www.ibmmainframes.com/viewtopic.php?t=29213&highlight=apostrophe
如果您使用 API,一个好方法是准备语句并将包含引号的文本绑定到参数。
请记住,允许某人输入引号并按原样插入(例如 sprintf(sqlstr, "INSERT INTO mytable VALUES ('%s')", inputstr);)可能会导致 SQL 注入。
我的输入:
可能会导致空数据库
if you are using the API, a good way is to prepare the statement and bind the quote-containing text to a parameter.
Remind that allowing someone to type in a quote and insert that unchanged (like sprintf(sqlstr, "INSERT INTO mytable VALUES ('%s')", inputstr);) may lead to an SQL-Injection.
my input:
may lead to an empty database