<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        徹底搞懂oracle的標量子查詢

        來源:懂視網(wǎng) 責編:小采 時間:2020-11-09 15:00:58
        文檔

        徹底搞懂oracle的標量子查詢

        徹底搞懂oracle的標量子查詢:oracle標量子查詢和自定義函數(shù)有時用起來比較方便,而且開發(fā)人員也經(jīng)常使用,數(shù)據(jù)量小還無所謂,數(shù)據(jù)量大,往往存在性能問題。 以下測試幫助大家徹底搞懂標量子查詢。 SQL create table a (id int,name varchar2(10)); Table created.
        推薦度:
        導讀徹底搞懂oracle的標量子查詢:oracle標量子查詢和自定義函數(shù)有時用起來比較方便,而且開發(fā)人員也經(jīng)常使用,數(shù)據(jù)量小還無所謂,數(shù)據(jù)量大,往往存在性能問題。 以下測試幫助大家徹底搞懂標量子查詢。 SQL create table a (id int,name varchar2(10)); Table created.

        oracle標量子查詢和自定義函數(shù)有時用起來比較方便,而且開發(fā)人員也經(jīng)常使用,數(shù)據(jù)量小還無所謂,數(shù)據(jù)量大,往往存在性能問題。 以下測試幫助大家徹底搞懂標量子查詢。 SQL create table a (id int,name varchar2(10)); Table created. SQL create table b (i

        oracle標量子查詢和自定義函數(shù)有時用起來比較方便,而且開發(fā)人員也經(jīng)常使用,數(shù)據(jù)量小還無所謂,數(shù)據(jù)量大,往往存在性能問題。
        以下測試幫助大家徹底搞懂標量子查詢。

        SQL> create table a (id int,name varchar2(10));
        Table created.
        SQL> create table b (id int,name varchar2(10));
        Table created.
        SQL> insert into a values (1,'a1');
        1 row created.
        SQL> insert into a values (2,'a2');
        1 row created.
        SQL> insert into b values (1,'b1');
        1 row created.
        SQL> insert into b values (2,'b2');
        1 row created.
        SQL> commit;
        Commit complete.
        SQL> @getlvall
        Session altered.
        SQL> select a.*,(select name from b where b.id=a.id) from a;
        ID NAME (SELECTNAMEFROMBWHER
        ---------- -------------------- --------------------
        1 a1 b1
        2 a2 b2
        SQL> @getplanspe
        PLAN_TABLE_OUTPUT
        --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        SQL_ID 8rv825dykpx1m, child number 0
        -------------------------------------
        select a.*,(select name from b where b.id=a.id) from a
        Plan hash value: 2657529235
        ------------------------------------------------------------------------------------
        | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
        ------------------------------------------------------------------------------------
        |* 1 | TABLE ACCESS FULL| B | 2 | 1 | 2 |00:00:00.01 | 14 |
        | 2 | TABLE ACCESS FULL| A | 1 | 2 | 2 |00:00:00.01 | 8 |
        ------------------------------------------------------------------------------------
        Predicate Information (identified by operation id):
        ---------------------------------------------------
        1 - filter("B"."ID"=:B1)
        Note
        -----
        - dynamic sampling used for this statement
        22 rows selected.
        由上面的執(zhí)行計劃可以知道,b表執(zhí)行2次,返回2行
        SQL> insert into a values (3,'a3');
        1 row created.
        SQL> commit;
        Commit complete.
        SQL> select a.*,(select name from b where b.id=a.id) from a;
        ID NAME (SELECTNAMEFROMBWHER
        ---------- -------------------- --------------------
        1 a1 b1
        2 a2 b2
        3 a3
        SQL> @getplanspe
        PLAN_TABLE_OUTPUT
        --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        SQL_ID 8rv825dykpx1m, child number 0
        -------------------------------------
        select a.*,(select name from b where b.id=a.id) from a
        Plan hash value: 2657529235
        ------------------------------------------------------------------------------------
        | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
        ------------------------------------------------------------------------------------
        |* 1 | TABLE ACCESS FULL| B | 3 | 1 | 2 |00:00:00.01 | 21 |
        | 2 | TABLE ACCESS FULL| A | 1 | 2 | 3 |00:00:00.01 | 8 |
        ------------------------------------------------------------------------------------
        Predicate Information (identified by operation id):
        ---------------------------------------------------
        1 - filter("B"."ID"=:B1)
        Note
        -----
        - dynamic sampling used for this statement
        22 rows selected.
        由上面的執(zhí)行計劃可以知道,b表執(zhí)行3次,返回2行
        SQL> insert into a values (4,'a4');
        1 row created.
        SQL> insert into a values (5,'a5');
        1 row created.
        SQL> insert into a values (6,'a6');
        1 row created.
        SQL> insert into a values (7,'a7');
        1 row created.
        SQL> insert into a values (8,'a8');
        1 row created.
        SQL> insert into a values (9,'a9');
        1 row created.
        SQL> commit;
        Commit complete.
        SQL> select a.*,(select name from b where b.id=a.id) from a;
        ID NAME (SELECTNAMEFROMBWHER
        ---------- -------------------- --------------------
        1 a1 b1
        2 a2 b2
        3 a3
        4 a4
        5 a5
        6 a6
        7 a7
        8 a8
        9 a9
        9 rows selected.
        SQL> @getplanspe
        PLAN_TABLE_OUTPUT
        --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        SQL_ID 8rv825dykpx1m, child number 0
        -------------------------------------
        select a.*,(select name from b where b.id=a.id) from a
        Plan hash value: 2657529235
        ------------------------------------------------------------------------------------
        | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
        ------------------------------------------------------------------------------------
        |* 1 | TABLE ACCESS FULL| B | 9 | 1 | 2 |00:00:00.01 | 63 |
        | 2 | TABLE ACCESS FULL| A | 1 | 2 | 9 |00:00:00.01 | 8 |
        ------------------------------------------------------------------------------------
        Predicate Information (identified by operation id):
        ---------------------------------------------------
        1 - filter("B"."ID"=:B1)
        Note
        -----
        - dynamic sampling used for this statement
        22 rows selected.
        由上面的執(zhí)行計劃可以知道,b表執(zhí)行9次,返回2行
        SQL> update b set name='b1';
        2 rows updated.
        SQL> commit;
        Commit complete.
        SQL> select a.*,(select name from b where b.id=a.id) from a;
        ID NAME (SELECTNAMEFROMBWHER
        ---------- -------------------- --------------------
        1 a1 b1
        2 a2 b1
        3 a3
        4 a4
        5 a5
        6 a6
        7 a7
        8 a8
        9 a9
        9 rows selected.
        SQL> @getplanspe
        PLAN_TABLE_OUTPUT
        --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        SQL_ID 8rv825dykpx1m, child number 0
        -------------------------------------
        select a.*,(select name from b where b.id=a.id) from a
        Plan hash value: 2657529235
        ------------------------------------------------------------------------------------
        | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
        ------------------------------------------------------------------------------------
        |* 1 | TABLE ACCESS FULL| B | 9 | 1 | 2 |00:00:00.01 | 63 |
        | 2 | TABLE ACCESS FULL| A | 1 | 2 | 9 |00:00:00.01 | 8 |
        ------------------------------------------------------------------------------------
        Predicate Information (identified by operation id):
        ---------------------------------------------------
        1 - filter("B"."ID"=:B1)
        Note
        -----
        - dynamic sampling used for this statement
        22 rows selected.
        由上面的執(zhí)行計劃可以知道,b表執(zhí)行2次,返回2行
        SQL> insert into b values (3,'b1');
        1 row created.
        SQL> insert into b values (4,'b1');
        1 row created.
        SQL> insert into b values (5,'b1');
        1 row created.
        insert into b values (6,'b1');b1');
        1 row created.
        SQL> insert into b values (7,'b1');
        1 row created.
        SQL> insert into b values (8,'b1');
        1 row created.
        SQL> insert into b values (9,'b1');
        1 row created.
        SQL> commit;
        Commit complete.
        SQL> select a.*,(select name from b where b.id=a.id) from a;
        ID NAME (SELECTNAMEFROMBWHER
        ---------- -------------------- --------------------
        1 a1 b1
        2 a2 b1
        3 a3 b1
        4 a4 b1
        5 a5 b1
        6 a6 b1
        7 a7 b1
        8 a8 b1
        9 a9 b1
        9 rows selected.
        SQL> @getplanspe
        PLAN_TABLE_OUTPUT
        --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        SQL_ID 8rv825dykpx1m, child number 0
        -------------------------------------
        select a.*,(select name from b where b.id=a.id) from a
        Plan hash value: 2657529235
        ------------------------------------------------------------------------------------
        | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
        ------------------------------------------------------------------------------------
        |* 1 | TABLE ACCESS FULL| B | 9 | 1 | 9 |00:00:00.01 | 63 |
        | 2 | TABLE ACCESS FULL| A | 1 | 2 | 9 |00:00:00.01 | 8 |
        ------------------------------------------------------------------------------------
        Predicate Information (identified by operation id):
        ---------------------------------------------------
        1 - filter("B"."ID"=:B1)
        Note
        -----
        - dynamic sampling used for this statement
        22 rows selected.
        b.name字段全部為‘b1’,由上面的執(zhí)行計劃可以知道,b表執(zhí)行9次,返回9行
        SQL> update a set id=1;
        9 rows updated.
        SQL> commit;
        Commit complete.
        SQL> select * from a;
        ID NAME
        ---------- --------------------
        1 a1
        1 a2
        1 a3
        1 a4
        1 a5
        1 a6
        1 a7
        1 a8
        1 a9
        9 rows selected.
        SQL> select * from b;
        ID NAME
        ---------- --------------------
        1 b1
        2 b1
        3 b1
        4 b1
        5 b1
        6 b1
        7 b1
        8 b1
        9 b1
        9 rows selected.
        SQL> select a.*,(select name from b where b.id=a.id) from a;
        ID NAME (SELECTNAMEFROMBWHER
        ---------- -------------------- --------------------
        1 a1 b1
        1 a2 b1
        1 a3 b1
        1 a4 b1
        1 a5 b1
        1 a6 b1
        1 a7 b1
        1 a8 b1
        1 a9 b1
        9 rows selected.
        SQL> @getplanspe
        PLAN_TABLE_OUTPUT
        --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        SQL_ID 8rv825dykpx1m, child number 0
        -------------------------------------
        select a.*,(select name from b where b.id=a.id) from a
        Plan hash value: 2657529235
        ------------------------------------------------------------------------------------
        | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
        ------------------------------------------------------------------------------------
        |* 1 | TABLE ACCESS FULL| B | 1 | 1 | 1 |00:00:00.01 | 7 |
        | 2 | TABLE ACCESS FULL| A | 1 | 2 | 9 |00:00:00.01 | 8 |
        ------------------------------------------------------------------------------------
        Predicate Information (identified by operation id):
        ---------------------------------------------------
        1 - filter("B"."ID"=:B1)
        Note
        -----
        - dynamic sampling used for this statement
        22 rows selected.
        SQL>
        關(guān)聯(lián)字段a.id全部為1,a表有9行,標量子查詢相當于執(zhí)行9次select name from b where b.id=1 ,oracle也不傻,starts=1,說明只執(zhí)行了1次。
        總結(jié):
        理想狀態(tài)下,a.id為主鍵,沒有重復值,那么a表返回多少行,b表就要被執(zhí)行多少次。
        特殊情況下,a.id的distinct值只有n個,那么b表只執(zhí)行n次。


        聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        徹底搞懂oracle的標量子查詢

        徹底搞懂oracle的標量子查詢:oracle標量子查詢和自定義函數(shù)有時用起來比較方便,而且開發(fā)人員也經(jīng)常使用,數(shù)據(jù)量小還無所謂,數(shù)據(jù)量大,往往存在性能問題。 以下測試幫助大家徹底搞懂標量子查詢。 SQL create table a (id int,name varchar2(10)); Table created.
        推薦度:
        標簽: 查詢 徹底 量子
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 77777_亚洲午夜久久多人| 亚洲中久无码永久在线观看同| 激情内射亚洲一区二区三区| a级特黄毛片免费观看| 亚洲高清成人一区二区三区| 亚洲AV日韩综合一区| 国产猛烈高潮尖叫视频免费| 亚洲va中文字幕| 国产无遮挡吃胸膜奶免费看视频| 亚洲精品宾馆在线精品酒店| 手机看片久久国产免费| 特级av毛片免费观看| 亚洲欧洲自拍拍偷精品 美利坚| 国产国产人免费人成成免视频| 久久夜色精品国产亚洲av| 国产免费拔擦拔擦8X高清在线人| 亚洲av无码无在线观看红杏| 3344免费播放观看视频| 亚洲另类自拍丝袜第1页| 成人性生活免费视频| 日韩成人精品日本亚洲| 精品国产人成亚洲区| 日韩精品内射视频免费观看| va天堂va亚洲va影视中文字幕| 久久精品网站免费观看| 成人精品国产亚洲欧洲| 亚洲熟女一区二区三区| 69视频在线观看免费| 亚洲人成网站18禁止| 免费人成视频x8x8入口| 日韩a级无码免费视频| 亚洲一区二区三区免费在线观看| 日韩成人免费视频播放| 久久久久久久久久免免费精品| 亚洲精品国产成人专区| 四虎免费在线观看| 久久久久久AV无码免费网站| 亚洲人成77777在线播放网站不卡| 亚洲A∨精品一区二区三区| 99爱在线观看免费完整版| 亚洲GV天堂无码男同在线观看|