oracle資料庫例外處理與視圖

來源:互聯網
上載者:User

標籤:

pl/sql例外處理

例 當輸入編號沒有時的例外處理

declare--定義v_ename emp.ename%type;begin--select ename into v_ename from emp where empno = &gno;dbms.output.put_line(‘名字:‘||v_ename);exceptionwhen no_data_found thendbms_output.put_line(‘編號沒有!‘);end;


--自訂例外

create or replace procedure ex_test(spNo number)is--定義例外myexcep exception;begin--更新update emp set sal = sal + 1000 where empno = spNo;--sql%notfound這是表示沒有update--raise myexcep 觸發myexcepif sql%notfound then raise myexcep;end if;exceptionwhen myexcep thendbms_output.put_line(‘沒有update‘);end;

 

oracle視圖
視圖是一個虛擬表,其內容由查詢定義,同真實的表一樣,視圖包含一系列帶有名稱的列和行資料,但是,視圖並不在
資料庫中以儲存的資料值集形式存在,行和列資料來自由定義視圖的查詢所引用的表,並且在引用視圖時動態產生。

表需要佔用磁碟空間,視圖不需要
視圖不能添加索引
使用視圖可以簡化複雜查詢

建立視圖create view myview as select * from emp where sal<1000;使用視圖select * from myview;利用視圖簡化操作create view myview2 as select emp.deptno,emp.name,dept.deptno from emp,dept where emp.deptno = dept.deptno;select * from myview2;

 

oracle資料庫例外處理與視圖

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.