AdventureWorks 中的資料類型

此主題列出 AdventureWorks 範例資料庫中代表的 Microsoft.NET Framework CLR 使用者定義型別、MicrosoftSQL Server 系統資料類型和 Transact-SQL 別名資料類型。

CLR 使用者定義型別

下表列出使用 CLR 使用者定義型別的 AdventureWorks 範例。您可以從 Microsoft SQL Server 範例和社群專案 (英文) 首頁下載這些範例。如需有關 CLR 使用者定義型別的詳細資訊,請參閱<CLR 使用者定義型別>。

範例

說明

SQL Server Database Engine 範例

使用 C# 語言定義 Currency 使用者定義資料類型。這種使用者定義資料類型同時封裝了總額及文化特性,有助於判定特定文化中顯示貨幣值總額的正確方式。範例也提供貨幣轉換函數,可傳回 Currency 使用者定義型別的實例。

UDT 公用程式

包含會將組件中繼資料公開給 Transact-SQL 的函數:將組件中的類型傳回為資料表的範例資料流資料表值函數,以及傳回使用者定義型別中的欄位、方法及屬性的函數。

使用者定義資料類型 (UDT) 範例

顯示由 Transact-SQL 與使用 System.Data.SqlClient 的用戶端應用程式,建立和使用簡單使用者定義資料類型的方法。

UTF8 字串使用者定義資料類型 (UDT)

顯示 UTF-8 使用者定義資料類型的實作,可擴展資料庫的類型系統,為 UTF-8 編碼值提供存放區。這種類型也可讓程式碼轉換 Unicode 字串與 UTF-8 字串。

日曆感知日期/時間 UDT

定義兩種使用者定義資料類型,即 CADatetimeCADate,它們提供處理日期和時間的行事曆認知能力。

陣列參數範例

使用 CLR 使用者定義資料類型,將整列資訊從用戶端傳送到伺服器上的 CLR 預存程序。

系統資料類型

下表列出 SQL Server 系統資料類型以及使用它們的資料表和資料行。如需關於系統資料類型的詳細資訊,請參閱<資料類型 (Transact-SQL)>。

資料類型

用於此 schema.table.column

bigint

不使用。

bit

請參閱下面別名資料類型段落中的 FlagNameStyle

char 或nchar

HumanResources.Employee.Gender

HumanResources.Employee.MaritalStatus

Person.StateProvince.StateProvinceCode

Production.BillOfMaterials.UnitMeasureCode

Production.Culture.CultureID

Production.Document.Revision

Production.Product.Class

Production.Product.ProductLine

Production.Product.SizeUnitMeasureCode

Production.Product.Style

Production.Product.WeightUnitMeasureCode

Production.ProductModelProductDescriptionCulture.CultureID

Production.TransactionHistory.TransactionType

Production.TransactionHistoryArchive.TransactionType

Production.UnitMeasure.UnitMeasureCode

Purchasing.ProductVendor.UnitMeasureCode

Sales.CountryRegionCurrency.CurrencyCode

Sales.CurrencyRate.FromCurrencyCode

Sales.CurrencyRate.ToCurrencyCode

Sales.Customer.CustomerType

Sales.Currency.CurrencyCode

datetime

所有資料表中的 ModifiedDate 資料行

dbo.AWBuildVersion.VersionDate

dbo.DatabaseLog.PostTime

HumanResources.Employee.BirthDate

HumanResources.Employee.HireDate

HumanResources.EmployeeDepartmentHistory.EndDate

HumanResources.EmployeeDepartmentHistory.StartDate

HumanResources.EmployeePayHistory.RateChangeDate

HumanResources.Shift.EndTime

HumanResources.Shift.StartTime

Production.BillOfMaterials.EndDate

Production.BillOfMaterials.StartDate

Production.Product.DiscontinuedDate

Production.Product.SellEndDate

Production.Product.SellStartDate

Production.ProductCostHistory.EndDate

Production.ProductCostHistory.StartDate

Production.ProductListPriceHistory.EndDate

Production.ProductListPriceHistory.StartDate

Production.TransactionHistory.TransactionDate

Production.TransactionHistoryArchive.TransactionDate

Production.WorkOrder.DueDate

Production.WorkOrder.EndDate

Production.WorkOrder.StartDate

Production.WorkOrderRouting.ActualEndDate

Production.WorkOrderRouting.ActualStartDate

Production.WorkOrderRouting.ScheduledEndDate

Production.WorkOrderRouting.ScheduledStartDate

Purchasing.ProductVendor.LastReceiptDate

Purchasing.PurchaseOrderDetail.DueDate

Purchasing.PurchaseOrderHeader.OrderDate

Purchasing.PurchaseOrderHeader.ShipDate

Sales.SalesCurrencyRate.CurrencyRateDate

Sales.SalesOrderHeader.DueDate

Sales.SalesOrderHeader.OrderDate

Sales.SalesOrderHeader.ShipDate

Sales.SalesPersonQuotaHistory.QuotaDate

Sales.SalesTerritoryHistory.EndDate

Sales.SalesTerritoryHistory.StartDate

Sales.ShoppingCartItem.DateCreated

Sales.SpecialOfferEndDate

Sales.SpecialOfferStartDate

decimal

Production.BillOfMaterials.PerAssemblyQty

Production.Location.Availability

Production.Product.Weight

Purchasing.PurchaseOrderDetail.ReceivedQty

Purchasing.PurchaseOrderDetail.RejectedQty

Purchasing.PurchaseOrderDetail.StockedQty

Production.WorkOrderRouting.ActualResourcesHrs

float

不使用。

image

不使用。請參閱<varbinary(max)>。

int

所有資料表。

money

HumanResources.EmployeePayHistory.Rate

Production.Product.ListPrice

Production.Product.StandardCost

Production.ProductCostHistory.StandardCost

Production.ProductListPriceHistory.ListPrice

Production.TransactionHistory.ActualCost

Production.TransactionHistoryArchive.ActualCost

Production.WorkOrderRouting.PlannedCost

Production.WorkOrderRouting.ActualCost

Purchasing.ProductVendor.LastReceiptCost

Purchasing.ProductVendor.StandardPrice

Purchasing.PurchaseOrderDetail.LineTotal

Purchasing.PurchaseOrderDetail.UnitPrice

Purchasing.PurchaseOrderHeader.Freight

Purchasing.PurchaseOrderHeader.SubTotal

Purchasing.PurchaseOrderHeader.TaxAmt

Purchasing.PurchaseOrderHeader.TotalDue

Purchasing.ShipMethod.ShipBase

Purchasing.ShipMethod.ShipRate

Sales.CurrencyRate.AverageRate

Sales.CurrencyRate.EndOfDayRate

Sales.SalesOrderDetail.UnitPrice

Sales.SalesOrderDetail.UnitPriceDiscount

Sales.SalesOrderHeader.Freight

Sales.SalesOrderHeader.SubTotal

Sales.SalesOrderHeader.TaxAmt

Sales.SalesOrderHeader.TotalDue

Sales.SalesPerson.Bonus

Sales.SalesPerson.SalesLastYear

Sales.SalesPerson.SalesYTD

Sales.SalesPersonQuotaHistory.SalesQuota

Sales.SalesTerritory.CostLastYear

Sales.SalesTerritory.CostYTD

Sales.SalesTerritory.SalesLastYear

Sales.SalesTerritory.SalesYTD

numeric

Sales.SalesOrderDetail.LineTotal

smallint

HumanResources.Department.DepartmentID

HumanResources.Employee.SickLeaveHours

HumanResources.Employee.VacationHours

HumanResources.EmployeeDepartmentHistory.DepartmentID

Production.BillOfMaterials.BOMLevel

Production.Location.LocationID

Production.Product.SafetyStockLevel

Production.Product.ReorderPoint

Production.ProductInventory.Quantity

Production.ProductInventory.LocationID

Production.WorkOrder.ScrappedQty

Production.WorkOrder.ScrapReasonID

Production.WorkOrderRouting.OperationSequence

Production.WorkOrderRouting.LocationID

Purchasing.PurchaseOrderDetail.OrderQty

Sales.CreditCard.ExpYear

Sales.SalesOrderDetail.OrderQty

smallmoney

Production.Location.CostRate

Sales.SalesPerson.CommissionPct

Sales.SalesTaxRate.TaxRate

Sales.SpecialOffer.DiscountPct

sysname

dbo.DatabaseLog.DatabaseUser

dbo.DatabaseLog.Event

dbo.DatabaseLog.Schema

dbo.DatabaseLog.Object

text 或ntext

不使用。請參閱<varchar(max)>或<nvarchar(max)>。

tinyint

dbo.AWBuildVersion.SystemInformationID

HumanResources.EmployeePayHistory.PayFrequency

HumanResources.EmployeeDepartmentHistory.ShiftID

HumanResources.EmployePayHistory.Rate

Production.Document.Status

Production.ProductInventory.Bin

Purchasing.PurchaseOrderHeader.RevisionNumber

Purchasing.PurchaseOrderHeader.Status

Purchasing.Vendor.CreditRating

Sales.CreditCard.ExpMonth

Sales.SalesOrderHeader.RevisionNumber

Sales.SalesOrderHeader.Status

Sales.SalesTaxRate.TaxType

uniqueidentifier

(GUID)

請參閱下列結構描述中資料表內的 ROWGUID 資料行:

  • Person

  • Sales

  • Product

在 AdventureWorks 中,ROWGUID 資料行用於複寫範例。

varbinary(max)

Production.Document.Document

Production.ProductPhoto.LargePhoto

Production.ProductPhoto.ThumbnailPhoto

varchar 或nvarchar

所有資料表。

varchar(max) 或

nvarchar(max)

Production.Document.DocumentSummary

dbo.DatabaseLog.TSQL

xml

dbo.DatabaseLog.XmlEvent

HumanResources.JobCandidate.Resume

Person.Contact.AdditionalContactInfo

Production.Illustration.Diagram

Production.ProductModel.CatalogDescription

Production.ProductModel.Instructions

Sales.Individual.Demographics

Sales.Store.Demographics

別名資料類型

下表列出別名資料類型、Transact-SQL 使用者自訂資料類型以及使用它們的資料表和資料行。如需關於別名資料類型的詳細資訊,請參閱<使用別名資料型別>。

資料類型名稱

定義為

用於此 schema.table.column

AccountNumber

nvarchar(15)

Sales.SalesOrderHeader.AccountNumber

Purchasing.Vendor.AccountNumber

Flag

bit

HumanResources.Employee.CurrentFlag

HumanResources.Employee.SalariedFlag

Person.StateProvince.IsOnlyStateProvinceFlag

Production.Product.FinishedGoodsFlag

Production.Product.MakeFlag

Production.ProductProductPhoto.Primary

Purchasing.Vendor.ActiveFlag

Purchasing.Vendor.PreferredVendorStatusFlag

Sales.SalesOrderHeader.OnlineOrderFlag

NameStyle

bit

Person.Contact.NameStyle

Name

nvarchar(50)

HumanResources.Department.GroupName

HumanResources.Department.Name

HumanResources.Shift.Name

Person.AddressType.Name

Person.Contact.FirstName

Person.Contact.LastName

Person.Contact.MiddleName

Person.ContactType.Name

Person.CountryRegion.Name

Person.StateProvince.Name

Production.Culture.Name

Production.Location.Name

Production.Product.Name

Production.ProductCategory.Name

Production.ProductModel.Name

Production.ProductReview.ReviewerName

Production.ProductSubcategory.Name

Production.ScrapReason.Name

Production.UnitMeasure.Name

Purchasing.ShipMethod.Name

Purchasing.Vendor.Name

Sales.Currency.Name

Sales.SalesReason.Name

Sales.SalesReason.ReasonType

Sales.SalesTaxRate.Name

Sales.SalesTerritory.Name

Sales.Store.Name

OrderNumber

nvarchar(25)

Sales.SalesOrderHeader.SalesOrderNumber

Phone

nvarchar(25)

Person.Contact.Phone