{"id":1264,"date":"2018-02-04T10:23:05","date_gmt":"2018-02-04T02:23:05","guid":{"rendered":"http:\/\/www.821121.com\/?p=1264"},"modified":"2021-01-05T17:54:05","modified_gmt":"2021-01-05T09:54:05","slug":"%e5%b8%b8%e7%94%a8sql%e8%af%ad%e5%8f%a5-%e5%bd%92%e6%a1%a3%e6%97%a5%e5%bf%97%e7%94%9f%e6%88%90%e6%83%85%e5%86%b5","status":"publish","type":"post","link":"http:\/\/www.821121.com\/?p=1264","title":{"rendered":"\u5e38\u7528sql\u8bed\u53e5-\u5f52\u6863\u65e5\u5fd7\u751f\u6210\u60c5\u51b5"},"content":{"rendered":"<p>--\u67e5\u770b\u751f\u6210\u5f52\u6863\u65e5\u5fd7\u4e2a\u6570<\/p>\n<pre><code class=\"language-sql\">SELECT \n      trunc(completion_time) &quot;Date&quot;,\n      to_char(completion_time, &#039;Dy&#039;) &quot;Day&quot;,\n      THREAD#,\n      dest_id,\n      count(1) &quot;Total&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;00&#039;,1,0)) &quot;h0_1&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;01&#039;,1,0)) &quot;h1_2&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;02&#039;,1,0)) &quot;h2_3&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;03&#039;,1,0)) &quot;h3_4&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;04&#039;,1,0)) &quot;h4_5&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;05&#039;,1,0)) &quot;h5_6&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;06&#039;,1,0)) &quot;h6_7&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;07&#039;,1,0)) &quot;h7_8&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;08&#039;,1,0)) &quot;h8_9&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;09&#039;,1,0)) &quot;h9_10&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;10&#039;,1,0)) &quot;h10_11&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;11&#039;,1,0)) &quot;h11_12&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;12&#039;,1,0)) &quot;h12_13&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;13&#039;,1,0)) &quot;h13_14&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;14&#039;,1,0)) &quot;h14_15&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;15&#039;,1,0)) &quot;h15_16&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;16&#039;,1,0)) &quot;h16_17&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;17&#039;,1,0)) &quot;h17_18&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;18&#039;,1,0)) &quot;h18_19&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;19&#039;,1,0)) &quot;h19_20&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;20&#039;,1,0)) &quot;h20_21&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;21&#039;,1,0)) &quot;h21_22&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;22&#039;,1,0)) &quot;h22_23&quot;,\n      SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;23&#039;,1,0)) &quot;h23_24&quot;\nFROM v$archived_log\ngroup by trunc(completion_time), \n         to_char(completion_time, &#039;Dy&#039;),\n         THREAD#,\n         dest_id\nOrder by 1 desc,3,4 \n; <\/code><\/pre>\n<p>--\u67e5\u770b\u751f\u6210\u5f52\u6863\u65e5\u5fd7\u5927\u5c0f<\/p>\n<pre><code class=\"language-sql\">SELECT \n      trunc(completion_time) &quot;Date&quot;,\n      to_char(completion_time, &#039;Dy&#039;) &quot;Day&quot;,\n      THREAD#,\n      dest_id,\n      round(sum(blocks*block_size)\/1024\/1024) &quot;Total_mb&quot;,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;00&#039;,blocks*block_size,0))\/1024\/1024) h0_1_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;01&#039;,blocks*block_size,0))\/1024\/1024) h1_2_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;02&#039;,blocks*block_size,0))\/1024\/1024) h2_3_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;03&#039;,blocks*block_size,0))\/1024\/1024) h3_4_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;04&#039;,blocks*block_size,0))\/1024\/1024) h4_5_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;05&#039;,blocks*block_size,0))\/1024\/1024) h5_6_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;06&#039;,blocks*block_size,0))\/1024\/1024) h6_7_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;07&#039;,blocks*block_size,0))\/1024\/1024) h7_8_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;08&#039;,blocks*block_size,0))\/1024\/1024) h8_9_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;09&#039;,blocks*block_size,0))\/1024\/1024) h9_10_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;10&#039;,blocks*block_size,0))\/1024\/1024) h10_11_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;11&#039;,blocks*block_size,0))\/1024\/1024) h11_12_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;12&#039;,blocks*block_size,0))\/1024\/1024) h12_13_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;13&#039;,blocks*block_size,0))\/1024\/1024) h13_14_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;14&#039;,blocks*block_size,0))\/1024\/1024) h14_15_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;15&#039;,blocks*block_size,0))\/1024\/1024) h15_16_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;16&#039;,blocks*block_size,0))\/1024\/1024) h16_17_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;17&#039;,blocks*block_size,0))\/1024\/1024) h17_18_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;18&#039;,blocks*block_size,0))\/1024\/1024) h18_19_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;19&#039;,blocks*block_size,0))\/1024\/1024) h19_20_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;20&#039;,blocks*block_size,0))\/1024\/1024) h20_21_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;21&#039;,blocks*block_size,0))\/1024\/1024) h21_22_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;22&#039;,blocks*block_size,0))\/1024\/1024) h22_23_mb,\n      round(SUM(decode(to_char(completion_time, &#039;hh24&#039;),&#039;23&#039;,blocks*block_size,0))\/1024\/1024) h23_24_mb\nFROM v$archived_log\ngroup by trunc(completion_time), \n         to_char(completion_time, &#039;Dy&#039;),\n         THREAD#,\n         dest_id\nOrder by 1 desc,3,4\n; <\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8211;\u67e5\u770b\u751f\u6210\u5f52\u6863\u65e5\u5fd7\u4e2a\u6570 SELECT trunc<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,48],"tags":[],"class_list":["post-1264","post","type-post","status-publish","format-standard","hentry","category-oracle-11g","category-sql"],"_links":{"self":[{"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/posts\/1264","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.821121.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1264"}],"version-history":[{"count":1,"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/posts\/1264\/revisions"}],"predecessor-version":[{"id":1265,"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/posts\/1264\/revisions\/1265"}],"wp:attachment":[{"href":"http:\/\/www.821121.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.821121.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1264"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.821121.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}