zoukankan      html  css  js  c++  java
  • ORACLE-PL/SQL学习笔记(一) 单行函数之字符处理函数

    /* 获取字符串长度函数:length(char)
    select  bookname ,length(bookname) from bookinfo; */

    /* 去除字符串首尾指定字符函数:trim([leading|trailing|both] [trim_character From] trim_source)
    select b_price2,length(b_price2),length(trim(b_price2)) from books5;
    leading 前缀字符
    trailing 后缀字符
    both 前后
    trim_character  From 要删除的指定字符串
    select trim(trailing 3 from trim(leading '1' from trim(b_price2))) from books5;
    select trim(trailing 3 from trim(leading '1' from trim(both ‘ ’ from b_price2))) from books5;*/

    /* 字符串截取函数:{[substr]|[substrb]|[substrc]|[substr2]|[substr4]}(char,position[,substring_length])
    substr 按字符截取,单位字符
    substrb 按字节,单位字节
    substrc unicode字符为单位
    substr2 ucs2代码点为单位
    substr4 ucs4代码点为单位
    char 参数,原始字符串
    position  开始位置,初始值1,-1表示从右侧开始
    substring_length 截取的长度
    select substr4(b_name,1,5) from books;
    select substr4(b_name,-1,5) from books; */

    /* 字符串连接函数:concat()
    select concat(b_id,b_name) from books;
    select concat(b_id,‘__’) from books;
    select concat(‘__’,b_id) from books;
    select (B_NAME||'__'||B_NAME) from books; */

    /* 小写字母转大写函数:upper(char)
    select upper(b_name) from books; */

    /* 大写字母转小写函数:lower(char)
    select lower(b_name) from books; */

    /* 检索字符串函数:{[instr]|[instrb]|[instrc]|[instr2]|[instr4]}(string,substring[,position[,occurrence]])
    instr 检索某个字符串在另一个字符串中出现的位置,以字符为单位,范围字符的位置
    instrb 返回字节的位置
    string 被检索的字符串
    substring 检索字符串
    position 开始位置,默认1
    occurrence substring第几次出现,默认1
    select b_name,instr(b_name,'basic') from books;
    select b_name,instr(b_name,'basic',1,1) from books;
    select b_name,instr('abcabdwe','b') from dual; */

  • 相关阅读:
    剑指offer——最小的K个数和数组中第K大的元素
    Leetcode刷题指南链接整理
    160. Intersection of Two Linked Lists
    100. Same Tree
    92. Reverse Linked List II
    94. Binary Tree Inorder Traversal
    79. Word Search
    78,90,Subsets,46,47,Permutations,39,40 DFS 大合集
    0x16 Tire之最大的异或对
    0x16 Tire
  • 原文地址:https://www.cnblogs.com/kevin-boy/p/3220350.html
Copyright © 2011-2022 走看看