当我尝试在 Oracle SQL Developer 2.1 中执行此语句时,会弹出一个对话框“输入替换变量”,询问 TOBAGO 的替换值,
update t set country = 'Trinidad and Tobago' where country = 'trinidad & tobago';
我怎样才能避免这种情况而不诉诸 chr(38)
或 u'trinidad \0026 tobago'
两者都掩盖了声明的目的?
在查询之前调用它:
set define off;
或者,hacky:
update t set country = 'Trinidad and Tobago' where country = 'trinidad &' || ' tobago';
SET DEFINE OFF 禁止解析命令以用它们的值替换替换变量。
在 SQL*Plus 中,将 SET DEFINE ?
放在脚本顶部通常可以解决此问题。也可能适用于 Oracle SQL Developer。
这将在没有 CHAR(38) 的情况下按照您的要求工作:
update t set country = 'Trinidad and Tobago' where country = 'trinidad & '|| 'tobago';
create table table99(col1 varchar(40));
insert into table99 values('Trinidad &' || ' Tobago');
insert into table99 values('Trinidad &' || ' Tobago');
insert into table99 values('Trinidad &' || ' Tobago');
insert into table99 values('Trinidad &' || ' Tobago');
SELECT * FROM table99;
update table99 set col1 = 'Trinidad and Tobago' where col1 = 'Trinidad &'||' Tobago';
chr(38)
的情况下做到这一点。
如果你使用 liquibase 运行 sql 文件,它不会报错。但是对于 sql 开发人员来说,在你的 sql sode 之前使用这个 set define off;
设置扫描关闭;上面的命令也有效。
set define off;
做什么(其他)?