【问题标题】:How to insert '&user' in oracle column? [duplicate]如何在 oracle 列中插入“&user”? [复制]
【发布时间】:2015-06-29 19:56:15
【问题描述】:

我的一个 oracle 数据库列需要具有值'user.password&user.user_name' 当我执行查询时,我会看到一个弹出窗口,因为查询中包含“&user”。我该如何解决?

查询示例:

update Table A set value = 'user.password&user.user_name' where id = 1;

【问题讨论】:

  • 我进行了搜索,但无法登陆该页面。抱歉重复了。

标签: database oracle


【解决方案1】:

chr(38) 应该独立于平台工作。

但是,如果您使用的是 SQL*Plus,那么您可以使用 sqlplus 命令:

set define off

在 SQL*Plus 中,& 符号用于替换变量。上面的命令会忽略它。

例如,

SQL> SET DEFINE OFF
SQL> SELECT 'user.password&user.user_name' FROM DUAL;

'USER.PASSWORD&USER.USER_NAM
----------------------------
user.password&user.user_name

SQL>

当然,chr(38) 也可以:

SQL> SELECT 'user.password'||chr(38)||'user.user_name' FROM dual;

'USER.PASSWORD'||CHR(38)||'U
----------------------------
user.password&user.user_name

SQL>

【讨论】:

    【解决方案2】:

    您可以在How do I ignore ampersands in a SQL script running from SQL Plus?找到几个决定

    顺便说一句,您可以只使用update table set value = &value where id = 1 并在弹出窗口中输入您的值。

    【讨论】:

      【解决方案3】:

      修改查询以插入值

      'user.password'||chr(38)||'user.user_name'
      

      查询示例:

      update Table A set value = 'user.password'||chr(38)||'user.user_name' where id = 1;
      

      【讨论】:

      • 'user.password'||'&'||'user.user_name' 应该也可以。
      • @evilive 当然可以。我现在因为有不必要的复杂事情而感到愚蠢。
      猜你喜欢
      • 2015-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多