1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| USE [AdventureWorks] GO IF EXISTS ( SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Employee_Demo_BTree') DROP TABLE Employee_Demo_BTree GO CREATE TABLE Employee_Demo_BTree( EmployeeID INT NOT NULL PRIMARY KEY, NationalIDNumber NVARCHAR(15) NOT NULL, ContactID INT NOT NULL, LoginID NVARCHAR(256) NOT NULL, ManagerID INT NULL, Title NVARCHAR(50) NOT NULL, BirthDate DATETIME NOT NULL, MaritalStatus NCHAR(1) NOT NULL, Gender NCHAR(1) NOT NULL, HireDate DATETIME NOT NULL, ModifiedDate DATETIME NOT NULL DEFAULT GETDATE() ) GO
CREATE NONCLUSTERED INDEX IX_Employee_ManagerID_Demo_BTree ON Employee_Demo_BTree([ManagerID] ASC) CREATE NONCLUSTERED INDEX IX_Employee_ModifiedDate_Demo_BTree ON Employee_Demo_BTree( [ModifiedDate] ASC)
INSERT [dbo].[Employee_Demo_BTree] SELECT [BusinessEntityID], [NationalIDNumber], [BusinessEntityID]+100, [LoginID], [BusinessEntityID]%50, [JobTitle], [BirthDate], [MaritalStatus], [Gender], [HireDate], [ModifiedDate] FROM [HumanResources].[Employee] GO
USE [AdventureWorks] GO IF EXISTS(SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Employee_Demo_Heap') DROP TABLE Employee_Demo_Heap GO CREATE TABLE Employee_Demo_Heap( EmployeeID INT NOT NULL, NationalIDNumber NVARCHAR(15) NOT NULL, ContactID INT NOT NULL, LoginID NVARCHAR(256) NOT NULL, ManagerID INT NULL, Title NVARCHAR(50) NOT NULL, BirthDate DATETIME NOT NULL, MaritalStatus NCHAR(1) NOT NULL, Gender NCHAR(1) NOT NULL, HireDate DATETIME NOT NULL, ModifiedDate DATETIME NOT NULL DEFAULT GETDATE() ) GO
CREATE NONCLUSTERED INDEX PK_Employee_EmployeeID_Demo_Heap ON Employee_Demo_Heap( [EmployeeID] ASC)
CREATE NONCLUSTERED INDEX IX_Employee_ManagerID_Demo_Heap ON Employee_Demo_BTree([ManagerID] ASC) CREATE NONCLUSTERED INDEX IX_Employee_ModifiedDate_Demo_Heap ON Employee_Demo_BTree( [ModifiedDate] ASC)
INSERT [dbo].[Employee_Demo_Heap] SELECT [BusinessEntityID], [NationalIDNumber], [BusinessEntityID]+100, [LoginID], [BusinessEntityID]%50, [JobTitle], [BirthDate], [MaritalStatus], [Gender], [HireDate], [ModifiedDate] FROM [HumanResources].[Employee] GO
|