70 likes | 182 Views
Module 6. Creating and Managing Databases. ◆OverView. Introduction Database Objects Creating Database Managing Databases Introduction to Data Structures. ◆ Introduction Database Objects. Table 資料表 Data Type 資料型態 Constraint 限制條件 Default 預設條件 Rule 資料規則 Index 索引設定.
E N D
Module 6 Creating and Managing Databases
◆OverView • Introduction Database Objects • Creating Database • Managing Databases • Introduction to Data Structures
◆ Introduction Database Objects • Table 資料表 • Data Type 資料型態 • Constraint 限制條件 • Default 預設條件 • Rule 資料規則 • Index 索引設定
補充Database 架構 • DataFile • Primary File(必要 預設存在) • *.mdf , Only one • 位於Primary File Group • 存放User Data & System Data • Secondary File(非必要 要自己建立) • *.ndf , 可擁有多個 • 存放Use Date • File Structures • Page • 8KB, Contiguous • Row的存放單位,不可跨Page存放,除非是Text ,Image ,Ntext的資料型別 • Extent • 8 Pages, Contiguous (64K) • Table & Index 的存放單位 • LogFile (必要 預設存在) • *.ldf 可擁有多個 • 存放用於Recorery的資訊
◆ Creating Database • 建立資料庫 Create Database Sample • 給定資料庫名稱 • 給定Data File及Log File的檔名與位置 • 設定資料庫大小 • 設定限制大小 • 設定增長量 • 任何資料採 Write-Ahead Log,預先寫入交易紀錄檔再寫入資料檔。 • 資料檔可以有多個,且可以用不同的檔案群組置放。設計原意為加快搜尋速度,但因目前伺服器及索引值的使用,以少有人如此區分。
◆ Managing Databases • 管理資料增長量 • 資料自動成長選項。 • 資料手動成長設定。 • 建立第二群組。 • 對交易紀錄檔之成長管理等同於資料記錄檔。 • 壓縮資料庫或檔案 • 可針對整個資料庫壓縮 Shrinkdatabase (SAMPLE,25) • 可針對檔案作壓縮 Shrinkfile (Sample_data,10) • 刪除資料庫 • Drop Database Sample1,Sample2
◆Introduction to Data Structures • Page • 8KB, Contiguous • Row的存放單位,不可跨Page存放,除非是Text ,Image ,Ntext的資料型別 • Extent • 8 Pages, Contiguous (64K) • Table & Index 的存放單位 • 只要是資料記錄檔都遵循上述架構 • 交易紀錄檔非上述檔案架構 • 每個資料記錄檔,每次增長以Extent為單位。 • 每個資料記錄檔的第一個Extent包含有其他資訊,因此稱為Mixed Extent。若是單純存放資料的Extent,則稱為Uniform Extent 或 Fully Mixed Extent。