Oracle 中的塊結構

來源:互聯網
上載者:User

PL/SQL 是一種塊結構的語言。

塊有但部分組成:定義部分,執行部分,異常處理部分。

文法結構:

declare 

/*

*    定義部分: 用於定義變數

*/

               變數名  變數類型

               v1  varchar2(10);

begin

/*

*        執行部分,用於賦值

*/

  v1 := '1111';

exception  

    異常部分

        when others then dbms _output.put_linel ('出錯')

end

特點:  變數區  專門定義變數的地方,不能在其他的定義變數

代碼區:執行正常的代碼

異常區:處理異常的地方  

不同的地區 功能不能 變。

小技巧: 定義數字最好不用number 浪費空間。用帶參方式

定義 varchar 一定要指定長度 ,(在指令碼中定長(char長度預設為1) ,變長(varchar必須定義長度<1-32767>,)

建表時,變長 欄位只能在 4000附近

相關文章

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.