我的一个oracle数据库列需要具有' user.password& user.user_name' 当我执行查询时,我看到一个弹出窗口,因为查询中有'& user'在里面。我该如何解决它?
示例查询:
update Table A set value = 'user.password&user.user_name' where id = 1;
答案 0 :(得分:1)
修改查询以插入值
'user.password'||chr(38)||'user.user_name'
示例查询:
update Table A set value = 'user.password'||chr(38)||'user.user_name' where id = 1;
答案 1 :(得分:0)
您可以在How do I ignore ampersands in a SQL script running from SQL Plus?
找到几个决定顺便说一句,您只需使用update table set value = &value where id = 1
并在弹出窗口中键入您的值。
答案 2 :(得分:0)
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>