`
shameant
  • 浏览: 57385 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

oracle 技巧补充

阅读更多

INSTR

Syntax

Description of instr.gif follows

Purpose

The INSTR functions search string for substring . The function returns an integer indicating the position of the character in string that is the first character of this occurrence. INSTR calculates strings using characters as defined by the input character set. INSTRB uses bytes instead of characters. INSTRC uses Unicode complete characters. INSTR2 uses UCS2 code points. INSTR4 uses UCS4 code points.

  • position is an nonzero integer indicating the character of string where Oracle Database begins the search. If position is negative, then Oracle counts backward from the end of string and then searches backward from the resulting position.

  • occurrence is an integer indicating which occurrence of string Oracle should search for. The value of occurrence must be positive.

Both string and substring can be any of the datatypes CHAR , VARCHAR2 , NCHAR , NVARCHAR2 , CLOB , or NCLOB . The value returned is of NUMBER datatype.

Both position and occurrence must be of datatype NUMBER , or any datatype that can be implicitly converted to NUMBER , and must resolve to an integer. The default values of both position and occurrence are 1, meaning Oracle begins searching at the first character of string for the first occurrence of substring . The return value is relative to the beginning of string , regardless of the value of position , and is expressed in characters. If the search is unsuccessful (if substring does not appear occurrence times after the position character of string ), then the return value is 0.

Examples

The following example searches the string CORPORATE FLOOR , beginning with the third character, for the string "OR ". It returns the position in CORPORATE FLOOR at which the second occurrence of "OR " begins:

SELECT INSTR('CORPORATE FLOOR','OR', 3, 2)
  "Instring" FROM DUAL;
 
  Instring
----------
        14

In the next example, Oracle counts backward from the last character to the third character from the end, which is the first O in FLOOR . Oracle then searches backward for the second occurrence of OR , and finds that this second occurrence begins with the second character in the search string :

SELECT INSTR('CORPORATE FLOOR','OR', -3, 2)
"Reversed Instring"
     FROM DUAL;
 
Reversed Instring
-----------------
               2

The next example assumes a double-byte database character set.

SELECT INSTRB('CORPORATE FLOOR','OR',5,2) "Instring in bytes"
   FROM DUAL;

Instring in bytes
-----------------
               
分享到:
评论

相关推荐

    Oracle 10g 学习笔记

    │ oracle技巧.txt │ ORACLE的索引和约束详解 - Oracle10g - 沪城篱笆.mht │ oracle里常用命令 - Oracle - 51CTO技术论坛_中国领先的IT技术社区.mht │ Sequence相关操作命令 - lvhuiqing的专栏 - CSDN博客.mht │...

    oracle 9i课件

    内容: Oracle对象关系数据库;...大型数据库设计原则(工程硕士补充);第3章 oracle数据库管理系统基本概念;第13章 脚本的编写;第16章 PowerBuilder高级开发技巧;管理Oracle数据库;数据字典等等!!!

    linux集群应用实战

    通过nagios的扩展插件补充nagios的监控功能 利用nrpe外部构件监控远程主机 利用飞信实现nagios短信报警功能 第13讲 heartbeat的概念组成以及工作原理 课程目标: 熟悉heartbeat的概念、组成和工作原理 课程内容: ...

    spring-boot-upload-file-lead-to-rce-tricks:spring boot Fat Jar 应用文件上传漏洞到 RCE 的利用技巧

    常见 JDK 目录收集欢迎提 issue 补充:clapping_hands:~/usr/lib/jvm/java-8-oracle/jre/lib//usr/lib/jvm/java-1.8-openjdk/jre/lib//usr/lib/jvm/java-8-openjdk-amd64/jre/lib/四. docker 漏洞环境的功能文件...

    JSP实践之旅.exe

    Tomcat.JSP JSWDK环境安装与配置 Resin服务器平台介绍 Resin在IIS...oracle上的应用 如何用UML为JSP建模 通用信息发布程序 JSP概述及音乐店设计 不用odbc直接连接SQL Server jsp的出错处理 ...

    asp.net知识库

    ASP.NET 2.0 正式版中无刷新页面的开发(示例代码的补充) ASP.NET2.0中themes、Skins轻松实现网站换肤! ASP.NET 2.0 中的代码隐藏和编译 ASP.NET 2.0 Language Swithcer and Theme Swicher 多语言转换和多样式主题...

    JavaScript-Java Bridge-crx插件

    这是Applets在其网页上以矩形显示图形的能力的补充。 但是,现在不建议使用Java插件和Applet,因为它们具有安全性和浏览器稳定性风险。 继续使用它们需要使用较旧的浏览器版本,并且不久之后将使用较旧的Java版本。 ...

    JAVA上百实例源码以及开源项目

     Java数据压缩与传输实例,可以学习一下实例化套按字、得到文件输入流、压缩输入流、文件输出流、实例化缓冲区、写入数据到文件、关闭输入流、关闭套接字关闭输出流、输出错误信息等Java编程小技巧。 Java数组倒置...

    JAVA上百实例源码以及开源项目源代码

     Java数据压缩与传输实例,可以学习一下实例化套按字、得到文件输入流、压缩输入流、文件输出流、实例化缓冲区、写入数据到文件、关闭输入流、关闭套接字关闭输出流、输出错误信息等Java编程小技巧。 Java数组倒置...

Global site tag (gtag.js) - Google Analytics