{"id":1258,"date":"2018-02-01T11:46:19","date_gmt":"2018-02-01T03:46:19","guid":{"rendered":"http:\/\/www.821121.com\/?p=1258"},"modified":"2021-01-05T11:47:43","modified_gmt":"2021-01-05T03:47:43","slug":"%e5%b8%b8%e7%94%a8sql%e8%af%ad%e5%8f%a5-%e8%a1%a8%e7%a9%ba%e9%97%b4%e4%bd%bf%e7%94%a8%e6%83%85%e5%86%b5","status":"publish","type":"post","link":"http:\/\/www.821121.com\/?p=1258","title":{"rendered":"\u5e38\u7528sql\u8bed\u53e5&#8211;\u8868\u7a7a\u95f4\u4f7f\u7528\u60c5\u51b5"},"content":{"rendered":"<p>--\u5305\u542b\u6570\u636e\u6587\u4ef6\u81ea\u52a8\u6269\u5c55<\/p>\n<pre><code class=\"language-sql\">SELECT  \nd.tablespace_name &quot;Name&quot;, \nd.status &quot;Status&quot;, \nd.contents &quot;Type&quot;, \nTO_CHAR(NVL(a.bytes \/ 1024 \/ 1024, 0),&#039;99G999G990D900&#039;) &quot;Size_MB&quot;, \nTO_CHAR(NVL(b.bytes - NVL(f.bytes, 0),0)\/1024\/1024, &#039;99G999G990D900&#039;) &quot;Used_MB&quot;, \nTO_CHAR(NVL((b.bytes - NVL(f.bytes, 0)) \/ a.bytes * 100, 0), &#039;990D00&#039;) &quot;Useds&quot; \nFROM sys.dba_tablespaces d, \n(SELECT tablespace_name, \nSUM( CASE WHEN autoextensible = &#039;YES&#039; THEN maxbytes when autoextensible = &#039;NO&#039; THEN bytes END) bytes\nFROM  dba_data_files  GROUP BY tablespace_name) a, \n(select tablespace_name, sum(bytes) bytes \nfrom dba_data_files group by tablespace_name) b,\n(select tablespace_name, sum(bytes) bytes\nfrom dba_free_space group by tablespace_name) f \nWHERE d.tablespace_name = a.tablespace_name(+) \nAND d.tablespace_name = f.tablespace_name(+)\nand d.tablespace_name = b.tablespace_name(+)\norder by 6;<\/code><\/pre>\n<p>--\u4e0d\u5305\u542b\u6570\u636e\u6587\u4ef6\u81ea\u52a8\u6269\u5c55<\/p>\n<pre><code class=\"language-sql\">SELECT d.tablespace_name &quot;Name&quot;,\n       d.extent_management,\n       d.status &quot;Status&quot;,\n       d.contents &quot;Type&quot;,\n       to_char(nvl(a.bytes \/ 1024 \/ 1024, 0), &#039;99G999G990D900&#039;) &quot;Size (MB)&quot;,\n       to_char(nvl(a.bytes - nvl(f.bytes, 0), 0) \/ 1024 \/ 1024,&#039;99G999G990D900&#039;) &quot;Used (MB)&quot;,\n       to_char(nvl((a.bytes - nvl(f.bytes, 0)) \/ a.bytes * 100, 0),&#039;990D00&#039;) &quot;Used%&quot;\n  FROM sys.dba_tablespaces d,\n       (SELECT tablespace_name, SUM(bytes) bytes\n          FROM dba_data_files\n         GROUP BY tablespace_name) a,\n       (SELECT tablespace_name, SUM(bytes) bytes\n          FROM dba_free_space\n         GROUP BY tablespace_name) f\n WHERE d.tablespace_name = a.tablespace_name(+)\n   AND d.tablespace_name = f.tablespace_name(+)\n   AND d.contents &lt;&gt; &#039;TEMPORARY&#039;\nUNION ALL\nSELECT d.tablespace_name &quot;Name&quot;,\n       d.extent_management,\n       d.status &quot;Status&quot;,\n       d.contents &quot;Type&quot;,\n       to_char(nvl(a.bytes \/ 1024 \/ 1024, 0), &#039;99,999,990.900&#039;) &quot;Size (MB)&quot;,\n       nvl(t.bytes, 0) \/ 1024 \/ 1024 || &#039;\/&#039; ||\n       nvl(a.bytes \/ 1024 \/ 1024, 0) &quot;Used (MB)&quot;,\n       to_char(nvl(t.bytes \/ a.bytes * 100, 0), &#039;990.00&#039;) &quot;Used%&quot;\n  FROM sys.dba_tablespaces d,\n       (SELECT tablespace_name, SUM(bytes) bytes\n          FROM dba_temp_files\n         GROUP BY tablespace_name) a,\n  (SELECT tablespace_name, SUM(bytes_cached) bytes\n          FROM v$temp_extent_pool\n         GROUP BY tablespace_name) t\n WHERE d.tablespace_name = a.tablespace_name(+)\n   AND d.tablespace_name = t.tablespace_name(+)\n   AND d.extent_management LIKE &#039;LOCAL&#039;\n   AND d.contents LIKE &#039;TEMPORARY&#039;\n ORDER BY 7 DESC;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8211;\u5305\u542b\u6570\u636e\u6587\u4ef6\u81ea\u52a8\u6269\u5c55 SELECT d.tab<\/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-1258","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\/1258","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=1258"}],"version-history":[{"count":1,"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/posts\/1258\/revisions"}],"predecessor-version":[{"id":1259,"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/posts\/1258\/revisions\/1259"}],"wp:attachment":[{"href":"http:\/\/www.821121.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.821121.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1258"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.821121.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}