<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
        主站蜘蛛池模板: 国产亚洲福利精品一区| 国产精品色午夜免费视频| 国产AV无码专区亚洲AV手机麻豆 | 亚洲精品国产精品| 免费做爰猛烈吃奶摸视频在线观看 | 91亚洲精品视频| 91免费在线播放| 亚洲高清无在码在线无弹窗| 污污网站18禁在线永久免费观看| 久久国产精品亚洲综合| 日韩免费高清大片在线| 亚洲午夜电影一区二区三区| 欧美好看的免费电影在线观看| 亚洲精品蜜夜内射| 免费在线观看理论片| 中文字幕在线免费播放| 久久久久亚洲AV无码专区首JN | 国产亚洲综合一区柠檬导航| 久久免费看少妇高潮V片特黄| 亚洲男女一区二区三区| 精品免费久久久久久成人影院| 黄色三级三级三级免费看| 久久精品国产精品亚洲下载| 久草福利资源网站免费| 亚洲另类自拍丝袜第1页| 日本免费人成黄页在线观看视频| 免费一级毛片在线播放放视频| 亚洲成AV人片在线观看无| 国产在线观看片a免费观看| 朝桐光亚洲专区在线中文字幕| 亚洲国产天堂久久久久久| 亚洲免费视频在线观看| 亚洲精品无码av中文字幕| 亚洲精品tv久久久久| 国产91免费视频| 日本高清不卡中文字幕免费| 中文字幕亚洲综合久久| 日韩毛片无码永久免费看| 韩日电影在线播放免费版| 亚洲男人天堂2018av| 区久久AAA片69亚洲|