{"id":329,"date":"2013-01-12T17:19:00","date_gmt":"2013-01-12T09:19:00","guid":{"rendered":"http:\/\/www.yallonking.com\/?p=329"},"modified":"2013-01-23T00:01:51","modified_gmt":"2013-01-22T16:01:51","slug":"%e8%a1%a8%e6%8c%aa%e5%8a%a8%e5%ad%98%e5%82%a8%e7%a9%ba%e9%97%b4%e5%90%8e%ef%bc%8c%e5%af%b9%e4%b9%8b%e4%b8%8a%e7%9a%84sql%e7%9a%84%e6%89%a7%e8%a1%8c%e8%ae%a1%e5%88%92%e7%9a%84%e5%bd%b1%e5%93%8d","status":"publish","type":"post","link":"http:\/\/www.yallonking.com\/?p=329","title":{"rendered":"\u8868\u632a\u52a8\u5b58\u50a8\u7a7a\u95f4\u540e\uff0c\u5bf9\u4e4b\u4e0a\u7684sql\u7684\u6267\u884c\u8ba1\u5212\u7684\u5f71\u54cd\u7684\u63a2\u7a76"},"content":{"rendered":"<p>\u8868\u632a\u52a8\u5b58\u50a8\u7a7a\u95f4\u540e\uff0c\u5bf9\u4e4b\u4e0a\u7684sql\u7684\u6267\u884c\u8ba1\u5212\u7684\u5f71\u54cd\u7684\u63a2\u7a76<\/p>\n<p>\u6570\u636e\u5e93\u7248\u672c\uff1a<\/p>\n<p>SQL&gt; SELECT * FROM (SELECT * FROM V$VERSION) WHERE ROWNUM&lt;5;<\/p>\n<p>BANNER<br \/>\n--------------------------------------------------------------------------------<br \/>\nOracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production<br \/>\nPL\/SQL Release 11.2.0.1.0 - Production<br \/>\nCORE 11.2.0.1.0 Production<br \/>\nTNS for Linux: Version 11.2.0.1.0 - Production<\/p>\n<p>\u6d4b\u8bd5\u8868\u4e3acsdn\u7684\u90a3\u4e2a600w+\u7684\u8868\uff0c\u5927\u5bb6\u61c2\u7684...<br \/>\nSQL&gt; desc csdn<br \/>\nName Null? Type<br \/>\n----------------------------------------- -------- ----------------------------<br \/>\nNAME VARCHAR2(30)<br \/>\nPASSWD VARCHAR2(100)<br \/>\nEMAIL VARCHAR2(100)<\/p>\n<p>SQL&gt; select * from (select name from csdn) where rownum&lt;3;<\/p>\n<p>NAME<br \/>\n------------------------------<br \/>\nzdg<br \/>\nLaoZheng<\/p>\n<p>SQL&gt; select table_name,tablespace_name from user_tables where table_name='CSDN';<\/p>\n<p>TABLE_NAME TABLESPACE_NAME<br \/>\n------------------------------ ------------------------------<br \/>\nCSDN A<\/p>\n<p>\u521b\u5efa\u6d4b\u8bd5\u7d22\u5f15<br \/>\nSQL&gt; create index idxcsdn on csdn(name);<\/p>\n<p>Index created.<\/p>\n<p>\u6536\u96c6\u5e76\u67e5\u770b\u6267\u884c\u8ba1\u5212<br \/>\nSQL&gt; explain plan for select name from csdn where name='zdg';<\/p>\n<p>Explained.<\/p>\n<p>SQL&gt; select * from table(dbms_xplan.display);<\/p>\n<p>PLAN_TABLE_OUTPUT<br \/>\n--------------------------------------------------------------------------------<br \/>\nPlan hash value: 141053954<\/p>\n<p>----------------------------------------------------------------------------<br \/>\n| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |<br \/>\n----------------------------------------------------------------------------<br \/>\n| 0 | SELECT STATEMENT | | 1 | 11 | 2 (0)| 00:00:01 |<br \/>\n|* 1 | INDEX RANGE SCAN| IDXCSDN | 1 | 11 | 2 (0)| 00:00:01 |<br \/>\n----------------------------------------------------------------------------<\/p>\n<p>Predicate Information (identified by operation id):<br \/>\n---------------------------------------------------<\/p>\n<p>1 - access(\"NAME\"='zdg')<\/p>\n<p>13 rows selected.<\/p>\n<p>\u6ce8\uff1a\u663e\u7136\u662f\u8d70\u7684\u7d22\u5f15idxcsdn<\/p>\n<p>\u632a\u52a8\u8868\u6240\u5728\u8868\u7a7a\u95f4<br \/>\nSQL&gt; alter table csdn move tablespace b;<\/p>\n<p>Table altered.<\/p>\n<p>\u518d\u6b21\u6536\u96c6\u5e76\u67e5\u770b\u6267\u884c\u8ba1\u5212<br \/>\nSQL&gt; explain plan for select name from csdn where name='zdg';<\/p>\n<p>Explained.<\/p>\n<p>SQL&gt; select * from table(dbms_xplan.display);<\/p>\n<p>PLAN_TABLE_OUTPUT<br \/>\n--------------------------------------------------------------------------------<br \/>\nPlan hash value: 3550140955<\/p>\n<p>--------------------------------------------------------------------------<br \/>\n| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |<br \/>\n--------------------------------------------------------------------------<br \/>\n| 0 | SELECT STATEMENT | | 1 | 11 | 6854 (1)| 00:01:23 |<br \/>\n|* 1 | TABLE ACCESS FULL| CSDN | 1 | 11 | 6854 (1)| 00:01:23 |<br \/>\n--------------------------------------------------------------------------<\/p>\n<p>Predicate Information (identified by operation id):<br \/>\n---------------------------------------------------<\/p>\n<p>1 - filter(\"NAME\"='zdg')<\/p>\n<p>13 rows selected.<\/p>\n<p>\u6ce8\uff1a\u663e\u7136\u4e0d\u8d70\u7d22\u5f15\uff0c\u800c\u662f\u5168\u8868\u626b\u63cf<\/p>\n<p>\u518d\u6b21\u5c06\u8868\u632a\u56de\u539f\u6765\u7684\u8868\u7a7a\u95f4<br \/>\nSQL&gt; alter table csdn move tablespace a;<\/p>\n<p>Table altered.<\/p>\n<p>\u518d\u6b21\u6536\u96c6\u5e76\u67e5\u770b\u6267\u884c\u8ba1\u5212<br \/>\nSQL&gt; explain plan for select name from csdn where name='zdg';<\/p>\n<p>Explained.<\/p>\n<p>SQL&gt; select * from table(dbms_xplan.display);<\/p>\n<p>PLAN_TABLE_OUTPUT<br \/>\n--------------------------------------------------------------------------------<br \/>\nPlan hash value: 3550140955<\/p>\n<p>--------------------------------------------------------------------------<br \/>\n| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |<br \/>\n--------------------------------------------------------------------------<br \/>\n| 0 | SELECT STATEMENT | | 1 | 11 | 6854 (1)| 00:01:23 |<br \/>\n|* 1 | TABLE ACCESS FULL| CSDN | 1 | 11 | 6854 (1)| 00:01:23 |<br \/>\n--------------------------------------------------------------------------<\/p>\n<p>Predicate Information (identified by operation id):<br \/>\n---------------------------------------------------<\/p>\n<p>1 - filter(\"NAME\"='zdg')<\/p>\n<p>13 rows selected.<\/p>\n<p>\u6ce8\uff1a\u5373\u4f7f\u632a\u56de\u539f\u6765\u7684\u8868\u7a7a\u95f4\uff0c\u8fd8\u662f\u4e0d\u8d70\u7d22\u5f15\uff0c\u8d70\u5168\u8868\u626b\u63cf<\/p>\n<p>\u91cd\u5efa\u7d22\u5f15<br \/>\nSQL&gt; alter index idxcsdn rebuild;<\/p>\n<p>Index altered.<\/p>\n<p>\u518d\u6b21\u6536\u96c6\u5e76\u67e5\u770b\u6267\u884c\u8ba1\u5212<br \/>\nSQL&gt; explain plan for select name from csdn where name='zdg';<\/p>\n<p>Explained.<\/p>\n<p>SQL&gt; select * from table(dbms_xplan.display);<\/p>\n<p>PLAN_TABLE_OUTPUT<br \/>\n--------------------------------------------------------------------------------<br \/>\nPlan hash value: 141053954<\/p>\n<p>----------------------------------------------------------------------------<br \/>\n| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |<br \/>\n----------------------------------------------------------------------------<br \/>\n| 0 | SELECT STATEMENT | | 1 | 11 | 2 (0)| 00:00:01 |<br \/>\n|* 1 | INDEX RANGE SCAN| IDXCSDN | 1 | 11 | 2 (0)| 00:00:01 |<br \/>\n----------------------------------------------------------------------------<\/p>\n<p>Predicate Information (identified by operation id):<br \/>\n---------------------------------------------------<\/p>\n<p>1 - access(\"NAME\"='zdg')<\/p>\n<p>13 rows selected.<\/p>\n<p>\u6ce8\uff1asql\u6267\u884c\u8ba1\u5212\u53c8\u6062\u590d\u6b63\u5e38!<\/p>\n<p>\u7ed3\u8bba\uff1a\u53ea\u8981\u8868\u632a\u52a8\u5230\u8868\u7a7a\u95f4\uff0c\u5176\u4e0a\u7684\u7d22\u5f15\u5747\u5931\u6548\uff0c\u65e0\u8bba\u662f\u632a\u5230\u65b0\u7684\u8868\u7a7a\u95f4\u6216\u662f\u632a\u56de\u539f\u59cb\u8868\u7a7a\u95f4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8868\u632a\u52a8\u5b58\u50a8\u7a7a\u95f4\u540e\uff0c\u5bf9\u4e4b\u4e0a\u7684sql\u7684\u6267\u884c\u8ba1\u5212\u7684\u5f71\u54cd\u7684\u63a2\u7a76 \u6570\u636e\u5e93\u7248\u672c\uff1a SQL&gt; SELECT * FRO [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[87],"tags":[],"_links":{"self":[{"href":"http:\/\/www.yallonking.com\/index.php?rest_route=\/wp\/v2\/posts\/329"}],"collection":[{"href":"http:\/\/www.yallonking.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.yallonking.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.yallonking.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.yallonking.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=329"}],"version-history":[{"count":5,"href":"http:\/\/www.yallonking.com\/index.php?rest_route=\/wp\/v2\/posts\/329\/revisions"}],"predecessor-version":[{"id":644,"href":"http:\/\/www.yallonking.com\/index.php?rest_route=\/wp\/v2\/posts\/329\/revisions\/644"}],"wp:attachment":[{"href":"http:\/\/www.yallonking.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.yallonking.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=329"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.yallonking.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}