其实这只是对null的一个处理,但这样的话索引就起不到作用了,所以性能会差
解决方案 »
- 请教高手SQL语句:用select的结果进行update
- sql 2000导入oracle 9i
- Oracle中的包(package)在重新编译成功后,其它会话访问仍会出现“失效”提示,高手帮兄弟一把
- 散分 顺便问路
- bulk insert 是什么意思??
- 这几组SQL语句效率哪个高?
- 我在一台机器上有两个实例,我用exp导出数据时,可何指定导出那个实例数据库
- sql 语句中or的问题
- PL/SQL中数组类型和RECORD类型使用求助!
- 比较逊的问题,采用oracle数据库一定要安装orcle客户端运行时程序吗?
- 求一查询语句难度巧高
- 建一nvarchar2字段,设置大小为2000,但在添加记录是却添加了6000个汉字也不会提示溢出,高手指教指教!
where nvl(Ect_Job,' ') like :shp_job_no
and nvl(ECT_INVOICE_NO,' ') like :shp_inv_no如果 shp_job_no参数为空会出现什么样的语句 ?
这个使用OacQruery组件的, 在参数中看到有个默认值为"%" 类型为STRING
where '' like % and ectinvoice_no like 'hhjj29993'
From Secstp00
where nvl(Ect_Job,' ') like 'HY16981'
and nvl(ECT_INVOICE_NO,' ') like '%'i/o成本:31 60个字节 全表扫描
而我换成
Select *
From Secstp00
where ect_job like 'HY16981'
and ECT_INVOICE_NO like '%'
i/o成本:2 540个字节 索引范围扫描
无法理解的是 为什么要用 nvl(Ect_Job,' ') 呢?
一般来讲 like左边都是字段名称啊,右边才是要查找的值! 写这个语句的人走了!!
一般来讲 like左边都是字段名称啊,右边才是要查找的值! 没有什么不可理解左 右
NULL NULL
not null not null
null not null
not null null
性能方面建立函数索引就可以吧?
左 右
'空格' like '%' 呀?
是把字段like比配查询,和字段null值替换,两种功能写在一起了,不过效率相当不乐观!
关键是理解nvl函数的返回值,我在网上查到了一下说明,供楼主参考:
The NVL function lets you substitutes a non-value when a null value is encountered.The syntax for the NVL function is:NVL (string1, replace_with )string1 is the string to test for a null value. replace_with is the value returned if string1 is null. Example:select NVL (commission, 0)
from sales;This SQL statement would return 0 if the commission field contained a null value. Otherwise, it would return the commission field.