AdventureWorks 内のデータ型

このトピックでは、AdventureWorks サンプル データベースで使用されている Microsoft.NET Framework の CLR ユーザー定義型、MicrosoftSQL Server のシステム データ型、および Transact-SQL の別名データ型に関する一覧を示します。

CLR ユーザー定義型

次の表は、AdventureWorks で CLR ユーザー定義型を使用しているサンプルの一覧です。これらのサンプルは、Microsoft SQL Server のサンプルとコミュニティのプロジェクトのホーム ページからダウンロードできます。CLR ユーザー定義型の詳細については、「CLR ユーザー定義型」を参照してください。

サンプル

説明

SQL Server データベース エンジン サンプル

C# を使用して Currency ユーザー定義データ型を定義しています。このユーザー定義データ型では、金額とカルチャが共にカプセル化されています。これにより、該当するカルチャの通貨で金額を表示するための適切な方法を決定することができます。このサンプルには、Currency ユーザー定義型のインスタンスを返す通貨換算関数も用意されています。

UDT ユーティリティ

アセンブリのメタデータを Transact-SQL に公開する関数が含まれています。これらの関数は、アセンブリ内の型をテーブルとして返すサンプル ストリーミング テーブル値関数や、ユーザー定義型のフィールド、メソッド、およびプロパティを返す関数です。

ユーザー定義データ型 (UDT) サンプル

シンプルなユーザー定義データ型の作成と使用について、Transact-SQL から行う方法と、System.Data.SqlClient を使用するクライアント アプリケーションから行う方法を示します。

UTF8 文字列ユーザー定義データ型 (UDT)

UTF-8 でエンコードされた値を格納するための、データベースの型システムを拡張する UTF-8 ユーザー定義データ型の実装方法を示します。この型では、Unicode と UTF-8 間で文字列を変換するコードも実装されます。

カレンダー対応の日付/時刻 UDT

カレンダーに応じた日付と時刻の処理を実現する、CADatetimeCADate という 2 つのユーザー定義型を定義します。

Array パラメーター サンプル

CLR ユーザー定義データ型を使用して、情報の配列をクライアントからサーバー上の CLR ストアド プロシージャに渡します。

システム データ型

次の表は、SQL Server のシステム データ型と、それらを使用するテーブルおよび列の一覧です。システム データ型の詳細については、「データ型 (Transact-SQL)」を参照してください。

データ型

使用場所 (schema.table.column)

bigint

使用しません。

bit

別名データ型に関するセクションの「Flag」および「NameStyle」を参照してください。

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