我不明白为什么我不能在我的视图中使用主键作为索引。
这是主表
CREATE TABLE [dbo].[xFedDBLogMsg](
[ID] [int] IDENTITY(1,1) NOT NULL,
[msgType] [int] NOT NULL,
[date] [datetime] NOT NULL,
[delay] [time](7) NOT NULL,
[error] [bit] NOT NULL,
[processID] [int] NULL,
CONSTRAINT [PK_tFedDBLogMsg] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
这是视图
CREATE VIEW [dbo].[tFedDBLogMsg]
AS
SELECT
L.ID
, L.msgType
, L.[date]
, M.MsgSent
, M.MsgReceived
, L.[delay]
, L.error
, L.processID
, NEWID() AS INTERNALID
FROM dbo.xFedDBLogMsg AS L
LEFT JOIN FedDBMsg.dbo.tFedDBLogMsg AS M ON (
M.ID = L.ID
)
这里是给我警告的程序:
ALTER PROCEDURE spGetFedDBErrorsByID (
@pIDS AS dbo.typeNumberList READONLY
)
AS
BEGIN
SELECT
MSG.ID
, MSG.msgType
, MSG.date
, MSG.MsgSent
, MSG.MsgReceived
FROM (
SELECT
CAST(ID.n AS INT) AS ID
FROM @pIDS AS ID
) AS X
INNER JOIN MyGolf.dbo.tFedDBLogMsg AS MSG WITH (INDEX(PK_tFedDBLogMsg)) ON (
MSG.ID = X.ID
)
END
GO
Warning: Index hints supplied for view 'MyGolf.dbo.tFedDBLogMsg' will be ignored.
PS:Lorem Ipsum 的段落有很多变体,但大多数都受到了某种形式的改变,注入了幽默,或者看起来甚至有点不可信的随机词。如果你要使用 Lorem Ipsum 的一段话,你需要确保文本中间没有隐藏任何令人尴尬的东西。Internet 上的所有 Lorem Ipsum 生成器都倾向于根据需要重复预定义的块,这使其成为 Internet 上第一个真正的生成器。它使用包含 200 多个拉丁词的字典,结合少量的模型句子结构,生成看起来合理的 Lorem Ipsum。因此,生成的 Lorem Ipsum 始终没有重复、注入幽默或非特征词等。