欢迎光临
我们一直在努力

ORACLE常用傻瓜問題1000問(之六)-数据库专栏,ORACLE

建站超值云服务器,限时71元/月

              oracle常用傻瓜問題1000問(之六)

作者:  ccbzzp

       大家在應用oracle的時候可能會遇到很多看起來不難的問題, 特別對新手來說, 今天我簡單把它總結一下, 發布給大家, 希望對大家有幫助! 和大家一起探討, 共同進步!

     對oracle高手來說是不用看的.

 
  
       oracle內部函數篇
204. 如何得到字符串的第一個字符的ascii值?
    ascii(char)
    select ascii(abcde) from dual;
    結果: 65

205. 如何得到數值n指定的字符?
    chr(n)
    select chr(68) from dual;
    結果: d

206. 如何連接兩個字符串?
    concat(char1,char2)
    select concat(abc,defgh) from dual;
    結果: abcdefgh

207. 如何將列中的數值代替為字符串?
    decode(char,n1,char1,n2,char2…)
    select decode(day,1,sun,2,mon) from dual;

208. initcap(char)
    將字符串char的第一個字符為大寫,其余為小寫.
    select initcap(abcde) from dual;

209. length(char)
    取一字符串char的長度.
    select length(abcde) from dual;

210. lower(char)
    將字符串char全部變為小寫.
    select lower(abcde) from dual;

211. lpad(char1,n,char2)
    用字符串char2包括的字符左填char1,使其長度為n.
    select lpad(abcdefg,10123) from dual;
    結果: 123abcdefg
 
212. ltrim(char,set)
    從字符串char的左邊移去字符串set中的字符,直到第一個不是set中的字符為止.
    select (cdefg,cd) from dual;
    結果: efg

213. nls_initcap(char)
    取字符char的第一個字符大寫,其余字符為小寫.
    select nls_initcap(abcde) from dual;

214. nls_lower(char)
    將字符串char包括的字符全部小寫.
    select nls_lower(aaaa) from dual;

215. nls_upper(char)
    將字符串char包括的字符全部大寫.
    select nls_upper(aaaa) from dual;

216. replace(char1,char2,char3)
    用字符串char3代替每一個列值為char2的列,其結果放在char1中.
    select replace(emp_no,123,456) from dual;

217. rpad(char1,n,char2)
    用字符串char2右填字符串char1,使其長度為n.
    select rpad(234,8,0) from dual;

218. rtrim(char,set)
    移去字符串char右邊的字符串set中的字符,直到最后一個不是set中的字符為止.
    select rtrim(abcde,de) from dual;

219. substr(char,m,n)
    得到字符串char從m處開始的n個字符. 雙字節字符,一個漢字為一個字符的.
    select substr(abcde,2,3) from dual;

220. substrb(char,m,n)
    得到字符串char從m處開始的n個字符. 雙字節字符,一個漢字為二個字符的.
    select substrb(abcde,2,3) from dual;

221. translate(char1,char2,char3)
    將char1中的char2的部分用char3代替.
    select translate(abcdefgh,de,mn) from  dual;

222. upper(char)
    將字符串char全部為大寫.

223. add_months(d,n)
    將n個月增加到d日期.
    select add_months(sysdate,5) from dual;

224. last_day(d)
    得到包含d日期的月份的最后的一天的日期.
    select last_day(sysdate) from dual;

225. month_between(d1,d2)
    得到兩個日期之間的月數.
    select month_between(d1,d2) from dual;

226. next_day(d,char)
    得到比日期d晚的由char命名的第一個周日的日期.
    select next_day(to_date(2003/09/20),satday) from dual;

227. rount(d,fmt)
    得到按指定的模式fmt舍入到的最進的日期.
    select rount(2003/09/20,month) from dual;

228. sysdate
    得到當前系統的日期和時間.
    select sysdate from dual;

229. to_char(d,fmt)
    將日期d轉換為fmt的字符串.
    select to_char(sysdate,yyyy/mm/dd) from dual;

230. to_date(char,fmt)
    將字符串char按fmt的格式轉換為日期.
    select to_date(2003/09/20,yyyy/mm/dd) from dual;

231. abs(n)
    得到n的絕對值.
    select abs(-6) from dual;

232. ceil(n)
    得到大于或等于n的最大整數.
    select ceil(5.6) from dual;

233. cos(n)
    得到n的余弦值.
    select cos(1) from dual;

234. sin(n)
    得到n的正弦值.
    select sin(1) from dual;

235. cosh(n)
    得到n的雙曲余弦值.
    select cosh(1) from dual;

236. exp(n)
    得到n的e的n次冪.
    select exp(1) from dual;

237. floor(n)
    得到小于或等于n的最小整數.
    select floor(5.6) from dual;

238. ln(n)
    得到n的自然對數.
    select ln(1) from dual;

239. log(m,n)
    得到以m為底n的對數.
    select log(2,8) from dual;

240. mod(m,n)
    得到m除以n的余數.
    select mod(100,7) from dual;

241. power(m,n)
    得到m的n冪.
    select power(4,3) from dual;

242. round(n,m)
    將n舍入到小數點后m位.
    select (78.87653,2) from dual;

243. sign(n)
    當n<0時,得到-1;
    當n>0時,得到1;
    當n=0時,得到0;
    select sign(99) from dual;

244. sinh(n)
    得到n的雙曲正弦值.
    select sinh(1) from dual;

245. sort(n)
    得到n的平方根,n>=0
    select sort(9) from dual;

246. tan(n)
    得到n的正切值.
    select tan(0) from dual;

247. tanh(n)
    得到n的雙曲正切值.
    select tanh(0) from dual;

248. trunc(n,m)
    得到在m位截斷的n的值.
    select trunc(7.7788,2) from dual;

249. count()
    計算滿足條件的記錄數.
    select count(*) from table1 where col1=aaa;

250. max()
    對指定的列求最大值.
    select max(col1) from table1;

251. min()
    對指定的列求最小值.
    select min(col1) from table1;

252. avg()
    對指定的列求平均值.
    select avg(col1) from table1;

253. sum()
    計算列的和.
    select sum(col1) from dual;

254. to_number(char)
    將字符轉換為數值.
    select to_number(999) from dual;

    待續…

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » ORACLE常用傻瓜問題1000問(之六)-数据库专栏,ORACLE
分享到: 更多 (0)

相关推荐

  • 暂无文章