注意:此页面搜索的是所有试题
题目内容 (软件工程)
你管理一个SQL Server 2008数据库,其中包含名为dbo.Sales的表,该表包含下面的表定义:
CREATE
TABLE [dbo].[Sales]([SalesID] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY
CLUSTERED,[OrderDate] [datetime] NOT NULL,[CustomerID] [int] NOT
NULL,[SalesPersonID] [int] NULL,[CommentDate] [date] NULL);
此表包含数百万条订单。你运行下面的查询来确定销售人员何时在dbo.Sales表中提供备注:
SELECT
SalesID,CustomerID,SalesPersonID,CommentDate FROM dbo.SalesWHERE CommentDate IS
NOT NULL AND SalesPersonID IS NOT NULL;
你发现此查询运行很慢。检查数据之后,你发现只有1%的行有备注日期,10%的行的SalesPersonID为null。你需要创建索引来优化此查询。索引必须在优化查询的同时节省磁盘空间。应创建哪个索引?
A.CREATE NONCLUSTERED INDEX idx1 ON dbo.Sales (CustomerID) INCLUDE (CommentDate,SalesPersonID);
B.CREATE NONCLUSTERED INDEX idx1 ON dbo.Sales (SalesPersonID) INCLUDE (CommentDate,CustomerID);
C.CREATE NONCLUSTERED INDEX idx1 ON dbo.Sales (CustomerID) INCLUDE(CommentDate) WHERE
SalesPersonID IS NOT NULL;
D.CREATE NONCLUSTERED INDEX idx1 ON dbo.Sales (CommentDate, SalesPersonID) INCLUDE(CustomerID) WHERE
CommentDate IS NOT NULL;

参考答案