Oracle 10g資料庫基礎之基本查詢語句-中-函數

來源:互聯網
上載者:User

函數:

使用函數的目的是為了操作資料

將輸入的變數處理,返回一個結果。

變數可以有好多。

傳入的變數可以是列的值,也可以是運算式。

函數可以嵌套。

內層函數的結果是外層函數的變數。

單行函數:每一行都有一個傳回值,但可以有多個變數。

多行函數:多行有一個傳回值。

單行函數的分類:

字元操作函數

數字操作函數

日期操作函數

資料類型轉換函式

綜合資料類型函數

字元操作函數:

大小寫操作函數

Lower,upper,initcap   小寫大寫首字母大寫

字串操作函數

Concat,length,substr,instr,trim,replace,lpad,rpad

實驗12:操作字串的函數

字元操作函數:

大小寫操作函數

Lower,upper,initcap   小寫大寫首字母大寫

字串操作函數

Concat,length,substr,instr,trim,replace,lpad,rpad

該實驗的目的是掌握常用的字串操作的函數.

字串的大小寫操作

SQL> Select lower(ename),upper(ename),initcap(ename) from emp;

SQL>Select lower(ename) 小寫字母,upper(ename) 大寫字母,initcap(ename) 首字母大寫 from emp;

相關閱讀:

Oracle 10g資料庫基礎之基本查詢語句-上
Oracle 10g資料庫基礎之基本查詢語句-中-函數
Oracle 10g資料庫基礎之基本查詢語句-下-串連&子查詢

SQL> select lower(' mf TR') 小寫字母, upper('mf TR') 大寫字母, initcap('mf TR') 首字母大寫 from dual;

Dual是虛表,讓我們用表的形式來訪問函數的值。

字串操作函數

Concat,length,substr,instr,trim,replace,lpad,rpad

其它字串操作函數

concat將兩個字元串連到一起

select ename,job,concat(ename,job) from emp;

求字串的長度

下面三句話是求字串的長度,字串要單引。

select length('張三') from dual;--按照字

select lengthb('張三') from dual;--按位元組

select lengthc('張三') from dual;--unicode的長度

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 下一頁

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.