Oracle Escape Characters:oracle 跳脱字符
2016-03-25 00:00
615 查看
摘要: 对于查询中间的的一些特殊字符,如果让它按照字面上去解释而不是当作特殊字符呢
一、Oracle 对于查询中间的的一些特殊字符,如果让它按照字面上去解释而不是当作特殊字符呢
Oracle allows the assignment of special escape characters to tell Oracle that the character is interpreted literally. Certain characters such as the underscore ?_? are not interpreted literally because they have special meaning within Oracle.
In the example below, we want to find all Oracle parameter that relate to I/O, so we are tempted to use the filter LIKE ?%_io_%?. Below we will select from the x$ksppi fixed table, filtering with the LIKE clause:
KSPPINM
--------------------------------
sessions
license_max_sessions
license_sessions_warning
_session_idle_bit_latches
_enable_NUMA_optimization
java_soft_sessionspace_limit
java_max_sessionspace_size
_trace_options
_io_slaves_disabled
dbwr_io_slaves
_lgwr_io_slaves
As you can see above, we did not get the answer we expected. The SQL displayed all values that contained ?io?, and not just those with an underscore. To remedy this problem, Oracle SQL supports an ESCAPE clause to tell Oracle that the character is to be interpreted literally:
KSPPINM
--------------------------------------
_io_slaves_disabled
dbwr_io_slaves
_lgwr_io_slaves
_arch_io_slaves
_backup_disk_io_slaves
backup_tape_io_slaves
_backup_io_pool_size
_db_file_direct_io_count
_log_io_size
fast_start_io_target
_hash_multiblock_io_count
_smm_auto_min_io_size
_smm_auto_max_io_size
_ldr_io_size
一、Oracle 对于查询中间的的一些特殊字符,如果让它按照字面上去解释而不是当作特殊字符呢
Oracle allows the assignment of special escape characters to tell Oracle that the character is interpreted literally. Certain characters such as the underscore ?_? are not interpreted literally because they have special meaning within Oracle.
In the example below, we want to find all Oracle parameter that relate to I/O, so we are tempted to use the filter LIKE ?%_io_%?. Below we will select from the x$ksppi fixed table, filtering with the LIKE clause:
select ksppinm from x$ksppi where ksppinm like '%_io_%';
KSPPINM
--------------------------------
sessions
license_max_sessions
license_sessions_warning
_session_idle_bit_latches
_enable_NUMA_optimization
java_soft_sessionspace_limit
java_max_sessionspace_size
_trace_options
_io_slaves_disabled
dbwr_io_slaves
_lgwr_io_slaves
As you can see above, we did not get the answer we expected. The SQL displayed all values that contained ?io?, and not just those with an underscore. To remedy this problem, Oracle SQL supports an ESCAPE clause to tell Oracle that the character is to be interpreted literally:
select ksppinm from x$ksppi where ksppinm like '%\_io\_%' ESCAPE '\';
KSPPINM
--------------------------------------
_io_slaves_disabled
dbwr_io_slaves
_lgwr_io_slaves
_arch_io_slaves
_backup_disk_io_slaves
backup_tape_io_slaves
_backup_io_pool_size
_db_file_direct_io_count
_log_io_size
fast_start_io_target
_hash_multiblock_io_count
_smm_auto_min_io_size
_smm_auto_max_io_size
_ldr_io_size
相关文章推荐
- 基于 Red Hat 的发行版 Oracle Linux 正式发布Oracle Linux 7.1
- Oracle Containers for J2EE远程安全漏洞(CVE-2014-0413)
- Oracle 10g R2不能使用EM的问题
- 表空间操作
- PreparedStatement中in子句的处理
- VMware下RedHat4.8_64位安装Oracle 10g RAC--简略脚本
- oracle sql日期比较
- 基于 Red Hat 的发行版 Oracle Linux 正式发布Oracle Linux 7.1
- OS block size和Oracle block size,查找OS Blocksize的方法
- oracle中创建数据库和表空间的几点总结
- 数据库自动备份脚本
- oracle的nvl函数的使用介绍
- 解决oracle用户连接失败的解决方法
- oracle的一些tips技巧
- Oracle 下的开发日积月累
- Oracle存储过程之数据库中获取数据实例
- Windows下ORACLE 10g完全卸载的方法分析
- Oracle 函数大全[字符串函数,数学函数,日期函数]第1/4页
- ORACLE LATERAL-SQL-INJECTION 个人见解