如何在sql中创建索引 [英] how to create index in sql
本文介绍了如何在sql中创建索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ALTER 功能 dbo.getThisPVFooterAmount( @ PVoucherHeaderId int , @ FooterAccountId int )
RETURNS money AS
BEGIN
return (从 trans_PurchaseVoucherDetails (< span class =code-keyword> nolock )
其中 PurchaseVoucherHeader_Id = @ PVoucherHeaderId 和 Record_Type = ' F' 和帐户_Id = @ FooterAccountId)
END
我有这个功能。如何在PurchaseVoucherHeader_Id上创建索引,Record_Type,Account_Id ????
解决方案
仅限对于相同的参数 - 确定性的函数 - 总是返回相同结果的函数可以被索引。
hi
CREATE INDEX index_name ON table_name(column_name)
ALTER FUNCTION dbo.getThisPVFooterAmount ( @PVoucherHeaderId int ,@FooterAccountId int)
RETURNS money AS
BEGIN
return (select Amount from trans_PurchaseVoucherDetails with (nolock)
where PurchaseVoucherHeader_Id=@PVoucherHeaderId and Record_Type ='F' And Account_Id =@FooterAccountId )
END
I have this function. how to create index on PurchaseVoucherHeader_Id,Record_Type,Account_Id ????
解决方案
Hi,
Only functions that always return the same result for the same parameters—functions that are deterministic—can be indexed.
hiCREATE INDEX index_name ON table_name (column_name)
这篇关于如何在sql中创建索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文