sql server 2000 TSQL:在表变量上创建索引 [英] sql server 2000 TSQL: creating index on table variable
本文介绍了sql server 2000 TSQL:在表变量上创建索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下可能吗?我无法这样做.我必须有一个永久表来创建索引吗?
Is the following possible? I am unable to do so. Do I have to have a permanent table to create index?
declare @Beatles table
(
LastName varchar(20) ,
FirstName varchar(20)
)
CREATE CLUSTERED INDEX Index_Name_Clstd ON @Beatles(LastName)
推荐答案
不,您不能在表变量上创建索引 - 请参阅此 这里的文章和这个在此处发帖 将本地、全局临时表与表变量进行比较.
No, you cannot create indices on a table variable - see this article here and this posting here comparing local, global temporary tables to table variables.
限制
您不能创建非集群表变量的索引,除非索引是 PRIMARY 的副作用表上的 KEY 或 UNIQUE 约束(SQL Server 强制执行任何 UNIQUE 或PRIMARY KEY 约束使用索引).
You cannot create a non-clustered index on a table variable, unless the index is a side effect of a PRIMARY KEY or UNIQUE constraint on the table (SQL Server enforces any UNIQUE or PRIMARY KEY constraints using an index).
这篇关于sql server 2000 TSQL:在表变量上创建索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文