Presentation is loading. Please wait.

Presentation is loading. Please wait.

Views ,Stored Procedures, User-defined Function, Triggers

Similar presentations


Presentation on theme: "Views ,Stored Procedures, User-defined Function, Triggers"— Presentation transcript:

1 Views ,Stored Procedures, User-defined Function, Triggers
Module 8 Views ,Stored Procedures, User-defined Function, Triggers

2 ◆Views Views的作用與好處 Defining View Modifying & Drop Views

3 Views的作用與好處Table 資料表 將資料表部分的資料產生成另一個檢視表 可結合不同的資料表產生 可用以隱藏機密性資料
可用以解決過度正規化的問題 不可用於提昇效能 不可修改資料

4 Defining View CREATE VIEW test AS SELECT OrderID, RequiredDate, ShippedDate, ContactName FROM Orders INNER JOIN Customers ON CustomerID = CustomerID go

5 Modifying & Drop Views 修改VIEW ALTER VIEW V_TEST AS SELECT OrderID, RequiredDate, ShippedDate, ContactName FROM Orders INNER JOIN Customers ON CustomerID = CustomerID Go 刪除VIEW DROP VIEW V_TEST

6 ◆ Stored Procedures 預存程序的作用與好處 建立,執行預存程序 修改,刪除預存程序 在預存程序中帶參數

7 預存程序的作用與好處 分散應用邏輯 隱藏機密資訊及資料表欄位 提昇效能 可配合新增刪除修改資料

8 建立,執行預存程序 建立預存程序 CREATE PROC X_TEST AS SELECT * FROM TSMC_EMPLOYEE GO
EXEC X_TEST 配合INSERT INTO語法 INSERT INTO CUSTOMERS EXEC X_TEST

9 修改,刪除預存程序 修改預存程序 ALTER PROC X_TEST AS SELECT * FROM TSMC_EMPLOYEE GO
DROP PROC X_TEST

10 在預存程序中帶參數 輸入參數 create proc X_Employee @E_Start char(6),@E_End char(6)
as select * from TSMC_employee where EMPLID between and order by emplid GO 執行輸入參數 EXEC X_Employee ‘000001’,’000010’ EXEC

11 在預存程序中帶參數 輸出參數 create proc X_Employee
@Start INT OUTPUT as SET GO 執行輸出參數 INT EXEC X_Employee OOUTPUT

12 ◆ User-defined Function
自訂函數的作用 建立自訂函數 自訂函數的種類

13 自訂函數的作用

14 建立自訂函數

15 自訂函數的種類

16 ◆ Triggers Triggers的作用 Trigger的運作原理 建立Trigger Trigger的種類

17 Triggers的作用

18 Trigger的運作原理

19 建立Trigger

20 Trigger的種類


Download ppt "Views ,Stored Procedures, User-defined Function, Triggers"

Similar presentations


Ads by Google