91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

怎么理解數據庫集合元素的刪除

發布時間:2021-11-08 13:57:46 來源:億速云 閱讀:117 作者:iii 欄目:關系型數據庫

這篇文章主要介紹“怎么理解數據庫集合元素的刪除”,在日常操作中,相信很多人在怎么理解數據庫集合元素的刪除問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”怎么理解數據庫集合元素的刪除”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

我創建了一個嵌套表類型和過程:

CREATE OR REPLACE TYPE plch_numbers_t IS TABLE OF NUMBER;
/
CREATE OR REPLACE PROCEDURE plch_show_numbers (
   title_in     IN VARCHAR2
, numbers_in   IN plch_numbers_t)
IS
BEGIN
   DBMS_OUTPUT.put_line (title_in);
   FOR rec IN (SELECT COLUMN_VALUE FROM TABLE (numbers_in))
   LOOP
      DBMS_OUTPUT.put_line (rec.COLUMN_VALUE);
   END LOOP;
END;
/

下面的選項用來代替下列代碼塊的 /*BODY*/ 注釋:

DECLARE
   l_numbers   plch_numbers_t
       := plch_numbers_t (12, 23, 34, 45, 56
                        , 67, 78, 89, 90, 100);
BEGIN
   /*BODY*/
   plch_show_numbers ('AFTER DELETE', l_numbers);
END;
/

哪些選項使得這個塊執行之后會顯示如下文本:

AFTER DELETE
23
45
67
89

換而言之,所有偶數元素都被刪除了。

(A)

FOR indx IN 1 .. l_numbers.COUNT
LOOP
   IF MOD (indx, 2) = 0
   THEN
      l_numbers.delete (indx);
   END IF;
END LOOP;
SQL> DECLARE
  2    l_numbers plch_numbers_t := plch_numbers_t(12,
  3                                               23,
  4                                               34,
  5                                               45,
  6                                               56,
  7                                               67,
  8                                               78,
  9                                               89,
 10                                               90,
 11                                               100);
 12  BEGIN
 13    FOR indx IN 1 .. l_numbers.COUNT LOOP
 14      IF MOD(indx, 2) = 0 THEN
 15        l_numbers.delete(indx);
 16      END IF;
 17    END LOOP;
 18  
 19    plch_show_numbers('AFTER DELETE', l_numbers);
 20  END;
 21  /
AFTER DELETE
12
34
56
78
90
PL/SQL procedure successfully completed
SQL>

(B)

FOR indx IN 1 .. l_numbers.COUNT
LOOP
   IF MOD (l_numbers (indx), 2) = 0
   THEN
      l_numbers.delete (indx);
   END IF;
END LOOP;
SQL> DECLARE
  2    l_numbers plch_numbers_t := plch_numbers_t(12,
  3                                               23,
  4                                               34,
  5                                               45,
  6                                               56,
  7                                               67,
  8                                               78,
  9                                               89,
 10                                               90,
 11                                               100);
 12  BEGIN
 13    FOR indx IN 1 .. l_numbers.COUNT LOOP
 14      IF MOD(l_numbers(indx), 2) = 0 THEN
 15        l_numbers.delete(indx);
 16      END IF;
 17    END LOOP;
 18  
 19    plch_show_numbers('AFTER DELETE', l_numbers);
 20  END;
 21  /
AFTER DELETE
23
45
67
89
PL/SQL procedure successfully completed
SQL>

(C)

DELETE FROM TABLE (l_numbers)
      WHERE MOD (index_value, 2) = 0;
SQL> DECLARE
  2    l_numbers plch_numbers_t := plch_numbers_t(12,
  3                                               23,
  4                                               34,
  5                                               45,
  6                                               56,
  7                                               67,
  8                                               78,
  9                                               89,
 10                                               90,
 11                                               100);
 12  BEGIN
 13    DELETE FROM TABLE(l_numbers) WHERE MOD(index_value, 2) = 0;
 14  
 15    plch_show_numbers('AFTER DELETE', l_numbers);
 16  END;
 17  /
DECLARE
  l_numbers plch_numbers_t := plch_numbers_t(12,
                                             23,
                                             34,
                                             45,
                                             56,
                                             67,
                                             78,
                                             89,
                                             90,
                                             100);
BEGIN
  DELETE FROM TABLE(l_numbers) WHERE MOD(index_value, 2) = 0;
  plch_show_numbers('AFTER DELETE', l_numbers);
END;
ORA-06550: 第 13 行, 第 15 列: 
PL/SQL: ORA-00903: 表名無效
ORA-06550: 第 13 行, 第 3 列: 
PL/SQL: SQL Statement ignored
SQL>

(D)

FOR rec IN (SELECT *
              FROM TABLE (l_numbers)
             WHERE MOD (COLUMN_VALUE, 2) = 0)
LOOP
   l_numbers.delete (rec.COLUMN_VALUE);
END LOOP;
SQL> DECLARE
  2    l_numbers plch_numbers_t := plch_numbers_t(12,
  3                                               23,
  4                                               34,
  5                                               45,
  6                                               56,
  7                                               67,
  8                                               78,
  9                                               89,
 10                                               90,
 11                                               100);
 12  BEGIN
 13    FOR rec IN (SELECT * FROM TABLE(l_numbers) WHERE MOD(COLUMN_VALUE, 2) = 0) LOOP
 14      l_numbers.delete(rec.COLUMN_VALUE);
 15    END LOOP;
 16  
 17    plch_show_numbers('AFTER DELETE', l_numbers);
 18  END;
 19  /
AFTER DELETE
12
23
34
45
56
67
78
89
90
100
PL/SQL procedure successfully completed
SQL>

實測答案為B

到此,關于“怎么理解數據庫集合元素的刪除”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

洞口县| 淮南市| 灵山县| 抚远县| 聂荣县| 大方县| 谢通门县| 中宁县| 锡林郭勒盟| 双流县| 于田县| 乌拉特前旗| 方城县| 长沙市| 团风县| 黄骅市| 错那县| 郎溪县| 台北市| 曲阜市| 德安县| 拜城县| 深州市| 广西| 汉源县| 哈密市| 佛学| 辽阳市| 蚌埠市| 比如县| 堆龙德庆县| 嘉善县| 金门县| 介休市| 右玉县| 柳江县| 兰考县| 鄂伦春自治旗| 桐庐县| 城步| 河源市|