部分常用sql,適用於oracle

上一個月時間:

to_char(add_months(sysdate, -1),'yyyymm')


字符串補零:

to_char(0.68,'FM9999990.0099') 


近10天:

select to_char((to_date(to_char(sysdate,'yyyymmdd'),'yyyymmdd') - 10) + rownum,'yyyymmdd') rq from dual a connect bylevel <= 10


同列按順序合併:

selectid, sys_connect_by_path(name, ',')
  from (select id,
               name,
               row_number() over(partitionby id order by name) rn,
               count(*) over(partitionby id) cnt
          from test1) a
 where level = cnt
 start with rn = 1
connect by prior id = id
       and prior
rn = rn – 1



生成32位隨機數:

 select  sys_guid() from dual


CLOB字段轉換成varchar:

dbms_lob.substr(clobcolumn,4000)




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章