Oracle
文章平均质量分 64
Oracle
练习一下
这个作者很懒,什么都没留下…
展开
-
Oracle 表被刪除后,如何恢復
--檢查這張表是否還在回收站,如果在,可恢復,反之,不能恢復select * from user_recyclebin where original_name='table_name';--如果該表已被重建,則需要給它重命名一下,反之,可跳過alter table table_name rename to table_name_1;--閃回flashback table table_...原创 2020-04-11 10:49:41 · 91 阅读 · 0 评论 -
Oracle-記一下使用full join的坑
full join就是一個大坑1. 坑1with tmp1as( select '1002' id, '錢二' name, 18 age from dual), tmp2as( select '1001' id, '趙一' name, '山東' address from dual), tmp3as( select '1001' id,...原创 2020-03-28 09:07:02 · 1721 阅读 · 0 评论 -
Oracle-行轉列pivot、列轉行unpivot
行轉列pivot示例1:with tmp_dataas( select '趙' surname, '15' qty from dual union all select '錢' surname, '16' qty from dual union all select '孫' surname, '17' qty from dual)sel...原创 2020-01-16 09:06:38 · 76 阅读 · 0 评论 -
Oracle-动态拆分字符串
示例1:select regexp_substr ('1,2,3', '[^,]+', 1,rownum) num from dual connect by rownum<=length('1,2,3')- length(regexp_replace('1,2,3', ',', ''))+1示例2:select regexp_substr('1,2,3',...原创 2020-01-14 15:42:51 · 249 阅读 · 0 评论 -
Oracle-分組求和
普通使用with tmp_tableas( select '1001' group1, 'a' group2, 'Y' group3, 1 num from dual union all select '1001' group1, 'a' group2, 'N' group3, 2 num from dual union all select...原创 2019-12-23 18:37:59 · 698 阅读 · 0 评论 -
Oracle-case when與decode
decode只有Oracle才有,且在處理大數據量時不如case whenwith tmp_tableas( select '1' col1 from dual union all select '2' col1 from dual union all select '3' col1 from dual)select col1, ...原创 2019-12-23 18:36:01 · 81 阅读 · 0 评论 -
Oracle-行合併
通常使用listagg即可,若合併后的字符串過長,可使用xmlagg示例1with tmp_tableas( select '1' col1 from dual union all select '2' col1 from dual union all select '3' col1 from dual)select listagg(c...原创 2019-12-23 18:29:17 · 89 阅读 · 0 评论