Oracle基本用法補充學習

2021-08-09 17:23:53 字數 1518 閱讀 4054

1字串函式

(1)大小寫轉換函式lower(待轉換的字串),將大寫轉換成小寫

select lower(ename) from emp ;
(2)將小寫轉換成大寫

select lower(ename) from emp ;
(3)將字串的首字母大寫

select  initcap(ename) from emp ;
(4)將兩個字串連線起來  (注意只能存在兩個字串)

select concat(ename,'hello') from emp ;
這裡需要注意 concat只能連線兩個字串 ,而||可以連線多個字串
--concat只能連線兩個字串,連線多個需要巢狀呼叫不方便

sql> select concat('aa','bb') from dual;

concat('aa','bb')

-----------------

aabb

--||直接連線多個字串

sql> select 'aa'||'bb'||'cc' from dual;

(5)擷取字串substr 存在3個引數

select  sub('helloworld',1,5) from dual ;

(6)檢視字串的長度length

select length(ename) from emp ;

(7)獲得字串某個字元的下標instr

select  instr('helloworld',5) from dual ;
(8)補齊字串lpad rpad

select lpad("hello",'10','*'') from dual  ;

select rpad("hello",'10','*') from dual ;

(9) trim函式

select trim(h from 'helloworld') from dual  ;   ----- elloworld

(10) replace函式

select replace('abcde','e','o') from dual ;    ------ abcdo
2數字函式

round(45.926,2)    ------ 45.93

trunc 截斷 trunc(45.926,2) ----45.92

mod 求餘 mod(1600,300) ----100

oracle學習 實時補充

1.建立表,將test 1中的列資料儲存到test 2中 務必不能少了as create table test 2 as select id,name,password from test 1 2.乙個列別名既能用在select子句也能用在order by子句中。不能在where子句中使用列別名 如...

學習總結 Oracle資料的基本用法

1.解鎖scott使用者 這句話的目的是為了檢視我登入的例項 select from v instance v 開頭的動態效能試圖 解鎖scott賬戶 select from dba users alter user scott identified by scott 2.建立tbl student...

pandas reindex用法 補充

import numpy as np import pandas as pd np.random.seed 666 s1 pd.series 1,2,3,4 index a b c d s2 pd.series a b c index 1,5,10 df1 pd.dataframe np.rando...