1 / 29

在 Microsoft Access 下 建立資料庫

在 Microsoft Access 下 建立資料庫.  建立資料表 ( Table). 建立資料表之幾種方式. 資料工作表檢視 設計檢視 資料表精靈 匯入資料表 連結資料表. 定義資料表. 定義欄位 欄位名稱、資料類型、敘述 欄位基本屬性: 欄位大小、格式、標題 、 預設值 是否需有資料、是否索引 驗證規則、驗證文字 輸入遮罩 定義主索引 定義資料表驗證規則 定義關聯 加入索引. 欄位驗證規則 ( Field Validation Rule).

berit
Download Presentation

在 Microsoft Access 下 建立資料庫

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 在Microsoft Access 下建立資料庫 建立資料表 (Table)

  2. 建立資料表之幾種方式 • 資料工作表檢視 • 設計檢視 • 資料表精靈 • 匯入資料表 • 連結資料表

  3. 定義資料表 • 定義欄位 • 欄位名稱、資料類型、敘述 • 欄位基本屬性:欄位大小、格式、標題、預設值 是否需有資料、是否索引 • 驗證規則、驗證文字 • 輸入遮罩 • 定義主索引 • 定義資料表驗證規則 • 定義關聯 • 加入索引

  4. 欄位驗證規則(Field Validation Rule) • Use the Validation Rule property for a field to define a simple check on the values that you allow in a field. • Access won't allow you to enter a field value that violates this rule. • When the rule is violated, a dialog window will appear to show the Validation Text(驗證文字).

  5. Field Validation Rule • In general, a field validation expression consists of • an operator and a comparison value. • Ex. > 100 • The operator can be omitted, if it’s an "equals" (=). • Ex. 100 means “= 100” • You can specify multiple comparisons separated by • the Boolean operators OR and AND. • Ex. (1). > 100 OR <0 OR 50 • (2). 200 OR (>0 AND <100) • Enclose text string values in “s. • Ex. “January”, “Bill Gates” • Enclose date constants in # ‘s. • Ex. #01/15/95#

  6. TABLE 5-4. Comparison symbols that can be used in validation rules Operator Meaning < Less than <= Less than or equal to > Greater than >= Greater than or equal to = Equal to <> Not equal to IN “Equal to" any member in a list; BETWEEN AND A range of values; comparison value must be two values LIKE A text or memo field to match a pattern string

  7. IN • IN (“Mon”, “Tue”, “Wed”) • IN (1,3,5,7) BETWEEN AND • Between 1 And 12 • Between #1/1/97# and #12/31/97# • Between #12:00:00 AM# And #12:00:00 PM#

  8. LIKE • Pattern字元 允許之字元 • ? 任意的單一字元。(SQL: _) • * 零個以上的字元。(SQL: %) • # 任一個數字(0-9)。 • [charlist] 在 charlist中的任一字元。 • [!charlist] 不在 charlist中的任一字元。 Like “[A-Z]#########” Like “??00####” Like “#####” Like “[!0-9BMQ]*####” Like “王????” Like “[!.,;]*” Like “*Smith##*” Like “[A-Z-]#[A-Z-]#[A-Z-]#”

  9. 資料表驗證規則 • 資料表驗證規則用於跨欄位(多欄位)之欄位輸入檢查。 Ex. 某欄位由另一欄位來決定 • 由資料表屬性中來編輯驗證規則/驗證文字。 • 欄位值之引用: [FieldName] Ex. [field1]+[field2]=100

  10. IIF 函數 IIf(expr, truepart, falsepart) 單元 描述 expr用來評估真偽的運算式。 true單元 如果expr為 True,則傳回這部份的值。 false單元 如果 expr為 False,則傳回這部份的值。 Ex: IIf(IsNull([num1]),Not(IsNull([num2])),True) IIf ([PayBy]<3, True, Left([CCNumber],1)=CStr([PayBy])) 如果[PayBy]<3 傳回 True值, 否則傳回 Left([CCNumber],1)=CStr([PayBy]) See Page 5-35

  11. 運算式建立幫手

  12. 定義輸入遮罩(Input Mask) • 讓使用者在欄位上看到輸入中之資料,以引導使用者輸入正確之資料。 • 適用於文字、數字、日期/時間、貨幣資料型態。 • 例如 (1). (_ _/_ _/_ _) (10/31/97) (2). ( _ _) _ _ _-_ _ _ _ (02)412-1234 (3). AN_ _ _@_ _ ANxyz@12

  13. 輸入遮罩屬性 輸入遮罩;儲存旗標;定位器字元 • 輸入遮罩:由輸入遮罩定義字元組成,描述輸入遮罩(欄位範本) • 儲存旗標: • 0: 連同輸入顯示字元一起存入欄位 • 1: 只儲存使用者輸入 • 定位器字元:待輸入空格位置之顯示字元 Ex: \(999\)000\-0000;0;”#” (###)###-####

  14. 輸入遮罩定義字元 0 數字 (0 至 9,需要輸入,不容許加 [+] 與減 [-] 的記號)。 9 數字或空格 (可不輸入,不容許加與減的記號)。 # 數字或空格 (可不輸入;在編輯模式下空格會以空白顯示, 但是當資料儲存後空白會被移除;容許加與減的記號). L字母 (A 至 Z,需要輸入)。 ? 字母 (A 至 Z,選擇性的輸入)。 A字母或數字 (需要輸入)。 a字母或數字 (選擇性的輸入)。 & 任何的字元或一個空格 (需要輸入)。 C任何的字元或一個空格 (選擇性的輸入)。

  15. 輸入遮罩定義字元 .小數點標位子元 ,千位分隔字元 : ; - / 日期與時間的分隔符號。 < 使所有字元被轉換成小寫。 > 使所有字元被轉換成大寫。 ! 使輸入遮罩從右到左顯示,而不從左到右顯示。 鍵入遮罩中的字元始終從左到右填滿遮罩。 \ 使接下來的字元以文字字元顯示 。 “一些字”直接顯示” ”中之字串 密碼 如同字元一樣的儲存,但以星號 (*) 顯示的。

  16. Access中文版 新增功能 遮罩字元 必須輸入 切換後模式 資料型態 @0 是 A全 數字 @9 否 A全 數字 @L是 A全 文字 @D是 ㄅ半 文數字 @d否 ㄅ半 文數字

  17. 輸入遮罩 範例數值 \(000\) 000\-0000 \(999\) 999\-9999 \(000\) AAA\-AAAA #999 >L????L?000L0 >L0L 0L0 00000\-9999 >L<?????????????? “SSN “000\-00\-0000 >LL00000\-0000 (206) 555-0248 (206) 555-0248 ( ) 555-0248 (206) 555-TELE -20 2000 GREENGR339M3 MAY R 452B7 T2F 8M4 98115- 98115-3007 Maria Brendan SSN 555-55-5555 DB51392-0493

  18. 定義主索引 • 主索引按鈕 • 單一欄位 主索引 • 多欄位 主索引

  19. 定義關聯 • 從工具/資料庫關聯圖 或 啟動 • 從“一”拖放到”多“ • 強迫參考完整性 • 串接更新相關欄位 • 串接刪除相關記錄 • 連接類型(Join) • 內部連接(Inner Join) • 外部連接(Outer Join):左邊外部連接(Left Join)、 右邊外部連接(Right Join)

  20. 產品編號 產品名稱 單價 廠商名稱 廠商TEL 廠商住址 產品編號 產品名稱 單價 廠商編號 1 統一豆漿 7 1 2 光泉牛奶 12 2 3 御飯團 18 1 廠商編號 廠商名稱 廠商TEL 廠商住址 1 統一 (02)25417281 台北市… 2 光泉 (02)12345678 台中市… 1 統一豆漿 7 統一 (02)25417281 台北市… 2 光泉牛奶 12 光泉 (02)12345678 台中市… 3 御飯團 18 統一 (02)25417281 台北市…  1

  21. Relationship: 1  

  22. 強迫參考完整性

  23. 連接類型(Join) Inner Join Outer Join Left Join Right Join

  24. 客戶編號 公司名稱 連絡人 定單編號 客戶編號 員工編號 FISSA 大統樂公司 FAMIA 10184

  25.   1 1 1 Inner Join Left Join Outer Join Right Join

  26. 加入索引 • 單一欄位索引 -可重複 -不可重複 • 多欄位索引

  27. Access資料庫限制 • A table can have up to 255 fields. • A table can have up to 32 indexes. • A multiple field index can have up to 10 columns. The sum of the lengths of the columns cannot exceed 255 bytes. • A row, excluding memo fields and OLE objects, can be no longer than approximately 2 kilobytes. • A memo/OLE field can store up to 1 GB. • An Access database cannot be larger than 1 GB.

More Related