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; */

  • 相关阅读:
    Hard Rock
    Codeforces Round #416 (Div. 2) B. Vladik and Complicated Book
    codeforces 793B. Igor and his way to work
    codeforces 1B Spreadsheets
    HDU 1069 Monkey and Banana
    codeforces 2B The least round way
    【机器学习】 通俗说拟合
    python-八皇后问题
    python-核心知识思维导图
    python-@property 属性
  • 原文地址:https://www.cnblogs.com/kevin-boy/p/3220350.html
Copyright © 2011-2022 走看看