我有这个观点,想知道如何制作“独特的索引视图”
ALTER VIEW vwCF
as
SELECT
cf.CashFlowID
,ftt.FTSName
,cf.FTSTypeID
,ftt.SortOrder AS ftsSortOrder
,cf.SecurityTypeID
,st.SecurityTypeName
,st.SortOrder AS stSortOrder
,cf.IssuanceDate
,cf.Issuance
,cf.Principal
,cf.Interest
,cf.FlowAmounts
,cf.Net
FROM dbo.CashFlow AS cf
INNER JOIN dbo.FinancialTimesType AS ftt ON cf.FTSTypeID = ftt.FTSTypeID
INNER JOIN dbo.SecurityType AS st ON cf.SecurityTypeID = st.SecurityTypeID
Go
如何创建独特的索引视图并从此处开始?感谢
答案 0 :(得分:0)
假设这是sql server,您可以使用下面的代码。您需要将底部的[id field]替换为您要使用的字段。
DROP VIEW vwCF
GO
CREATE VIEW vwCF WITH SCHEMABINDING
AS
cf.CashFlowID
,ftt.FTSName
,cf.FTSTypeID
,ftt.SortOrder AS ftsSortOrder
,cf.SecurityTypeID
,st.SecurityTypeName
,st.SortOrder AS stSortOrder
,cf.IssuanceDate
,cf.Issuance
,cf.Principal
,cf.Interest
,cf.FlowAmounts
,cf.Net
FROM dbo.CashFlow AS cf
INNER JOIN dbo.FinancialTimesType AS ftt
ON cf.FTSTypeID = ftt.FTSTypeID
INNER JOIN dbo.SecurityType AS st
ON cf.SecurityTypeID = st.SecurityTypeID;
CREATE UNIQUE CLUSTERED INDEX idx_vwCf ON vwCF ([id field]);
[有关索引视图的更多信息]:http://msdn.microsoft.com/en-us/library/ms191432.aspx