substr擷取字串
Purpose
The SUBSTR
functions return a portion of char
, beginning at character position
, substring_length
characters long. SUBSTR
calculates lengths using characters as defined by the input character set. SUBSTRB
uses bytes instead of characters. SUBSTRC
uses Unicode complete characters. SUBSTR2
uses UCS2 code points. SUBSTR4
uses UCS4 code points.
If
position
is 0, then it is treated as 1.If
position
is positive, then Oracle Database counts from the beginning ofchar
to find the first character.If
position
is negative, then Oracle counts backward from the end ofchar
.If
substring_length
is omitted, then Oracle returns all characters to the end ofchar
. Ifsubstring_length
is less than 1, then Oracle returns null.
char
can be any of the datatypes CHAR
, VARCHAR2
, NCHAR
, NVARCHAR2
, CLOB
, or NCLOB
. Both position
and substring_length
must be of datatype NUMBER
, or any datatype that can be implicitly converted to NUMBER
, and must resolve to an integer. The return value is the same datatype as char
. Floating-point numbers passed as arguments to SUBSTR
are automatically converted to integers.
See Also:
Oracle Database Globalization Support Guide for more information aboutSUBSTR
functions and length semantics in different localesExamples
The following example returns several specified substrings of "ABCDEFG":
SELECT SUBSTR('ABCDEFG',3,4) "Substring" FROM DUAL; Substring --------- CDEF SELECT SUBSTR('ABCDEFG',-5,4) "Substring" FROM DUAL; Substring --------- CDEF
Assume a double-byte database character set:
SELECT SUBSTRB('ABCDEFG',5,4.2) "Substring with bytes" FROM DUAL; Substring with bytes -------------------- CD[@more@]
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/14181270/viewspace-1059354/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 字串擷取 slice,substr,substring 的區別字串
- js字串擷取函式slice()、substring()、substr()JS字串函式
- Javascript之字串擷取函式slice()、substring()、substr()JavaScript字串函式
- JS字串擷取函式slice(),substring(),substr()的區別JS字串函式
- substr擷取函式 筆記函式筆記
- 字串擷取字串
- PHP字串擷取PHP字串
- php字串擷取函式,支援中文擷取PHP字串函式
- Js中substr,substring,slice擷取字串的異同JS字串
- MySQL 字串函式:字串擷取MySql字串函式
- php中英字串擷取PHP字串
- jQuery字串擷取詳解jQuery字串
- iOS擷取NSString字串iOS字串
- Mysql字串擷取函式MySql字串函式
- JS字串擷取函式slice(),substring(),substr()的用法 區別split()後期遇到補充JS字串函式
- 擷取字串的三種方法 substr,slice,substring的區別字串
- substr()擷取前5個字元後面省略號的方法字元
- iOS NSString字串擷取方法iOS字串
- shell 擷取變數的字串變數字串
- JavaScript 擷取指定指定區間字串JavaScript字串
- Shell中的字串擷取介紹字串
- php 擷取中英文混合字串PHP字串
- C#常用字串擷取C#字串
- shell 使用陣列及字串擷取陣列字串
- Swift 4.0 字串擷取,拼接,字串富文字顯示Swift字串
- Linux下的字串擷取詳解Linux字串
- javascript擷取指定指定區間的字串JavaScript字串
- swift 字串學習 (index用法和擷取)Swift字串Index
- iOS擷取特定的字串(正則匹配)iOS字串
- php 如何擷取中文字串PHP字串
- Linux shell指令碼的字串擷取Linux指令碼字串
- sql常用函式詳解(一)——字串擷取SQL函式字串
- MySQL 字串擷取相關函式總結MySql字串函式
- 擷取字串字串
- css實現的字串擷取程式碼例項CSS字串
- 對url字串中域名的三種擷取方式字串
- javascript擷取指定長度字串相容中英文JavaScript字串
- 包含中文的字串中擷取前N個字元字串字元