DB2 不保存风格化的撇号 (’)

发布于 2024-11-24 07:06:01 字数 269 浏览 5 评论 0原文

我正在尝试将程式化的撇号 (') 插入到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

可爱咩 2024-12-01 07:06:03

您的数据库/表空间的编码是什么?我怀疑它需要设置为UTF-8。您可能需要创建一个新的表空间或重新创建数据库,并将编码显式设置为 UTF-8。

确定编码,运行以下命令并查找“Code set”信息:

db2 get db cfg for <database name>

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 get db cfg for <database name>
兲鉂ぱ嘚淚 2024-12-01 07:06:03

来自在 DB2 表中插入撇号

 insert into userid.empy values(1234,'RAM'''); 

您已输入 2 个单引号,单引号将出现在
表。

参见:
http://www.ibmmainframes.com/viewtopic.php?t=36901& ;highlight=撇号
http://www.ibmmainframes.com/viewtopic.php?t=29213& ;突出显示=撇号

from Inserting an Apostrophe in DB2 table

 insert into userid.empy values(1234,'RAM'''); 

You have put 2 Single Quotations, for a single quote to appear in the
table.

see also:
http://www.ibmmainframes.com/viewtopic.php?t=36901&highlight=apostrophe and
http://www.ibmmainframes.com/viewtopic.php?t=29213&highlight=apostrophe

恋你朝朝暮暮 2024-12-01 07:06:03

如果您使用 API,一个好方法是准备语句并将包含引号的文本绑定到参数。

请记住,允许某人输入引号并按原样插入(例如 sprintf(sqlstr, "INSERT INTO mytable VALUES ('%s')", inputstr);)可能会导致 SQL 注入。

我的输入:

测试');删除数据库;插入到mytable值('测试

可能会导致空数据库

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:

test');drop database;insert into mytable values ('test

may lead to an empty database

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文