包含在 SQL Server 2008 Express 中的覆盖索引中不可用

发布于 2024-10-02 22:06:12 字数 1937 浏览 2 评论 0原文

在 MS SQL Server Manager Studio for 2008 Express 中,数据库图表设计器的“索引/键”窗口中的“包含的列”字段始终显示为灰色。

根据帮助,只要我不创建聚集索引,就应该可用。

此外,如果我运行查询来创建索引(运行良好),则创建的查询不会列出它所添加的表。

我没有看到 MS 说 Express 版本中不提供此功能的任何地方。

有什么想法吗?

更多数据:

这是创建表的脚本:

CREATE UNIQUE INDEX IX_SocialTypes_Cover ON ClientSocialTypes(ClientID, SocialTypeID, [Source]) INCLUDE (URLID)

这是表生成脚本(缺少索引):

CREATE TABLE [dbo].[ClientSocialTypes](
    [SocialTypeID] [int] IDENTITY(1,1) NOT NULL,
    [ClientID] [int] NOT NULL,
    [SocialTypeClassID] [tinyint] NOT NULL,
    [Source] [nvarchar](50) NOT NULL,
    [TagCount] [int] NOT NULL,
    [URLID] [int] NULL,
 CONSTRAINT [PK_ClientSources] PRIMARY KEY CLUSTERED 
(
    [SocialTypeID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]    
GO

ALTER TABLE [dbo].[ClientSocialTypes]  WITH CHECK ADD  CONSTRAINT [FK_ClientSocialTypes_Clients] FOREIGN KEY([ClientID])
REFERENCES [dbo].[Clients] ([ClientID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[ClientSocialTypes] CHECK CONSTRAINT [FK_ClientSocialTypes_Clients]
GO

ALTER TABLE [dbo].[ClientSocialTypes]  WITH CHECK ADD  CONSTRAINT [FK_ClientSocialTypes_SocialTypeClasses] FOREIGN KEY([SocialTypeClassID])
REFERENCES [dbo].[SocialTypeClasses] ([SocialTypeClassID])
GO

ALTER TABLE [dbo].[ClientSocialTypes] CHECK CONSTRAINT [FK_ClientSocialTypes_SocialTypeClasses]
GO

ALTER TABLE [dbo].[ClientSocialTypes] ADD  CONSTRAINT [DF_ClientSocialTypes_SocialTypeClassID]  DEFAULT ((1)) FOR [SocialTypeClassID]
GO

ALTER TABLE [dbo].[ClientSocialTypes] ADD  CONSTRAINT [DF_ClientSocialTypes_TagCount]  DEFAULT ((0)) FOR [TagCount]
GO

ALTER TABLE [dbo].[ClientSocialTypes] ADD  CONSTRAINT [DF_ClientSocialTypes_HasTrackedURL]  DEFAULT ((0)) FOR [URLID]
GO

In MS SQL Server Manager Studio for 2008 Express, the "Included Columns" field is always grayed out in the "Indexes/Keys" window in the Database Diagram designer.

Per the help, this should be available so long as I'm not creating a clustered index.

Further, if I run a query to create the index (which runs fine), the created query doesn't list for the table it was added against.

I don't see anywhere where MS says this feature is unavailable in the Express version.

Any ideas?

Further data:

This is the script that creates the table:

CREATE UNIQUE INDEX IX_SocialTypes_Cover ON ClientSocialTypes(ClientID, SocialTypeID, [Source]) INCLUDE (URLID)

Here is the table gen script (the index is missing):

CREATE TABLE [dbo].[ClientSocialTypes](
    [SocialTypeID] [int] IDENTITY(1,1) NOT NULL,
    [ClientID] [int] NOT NULL,
    [SocialTypeClassID] [tinyint] NOT NULL,
    [Source] [nvarchar](50) NOT NULL,
    [TagCount] [int] NOT NULL,
    [URLID] [int] NULL,
 CONSTRAINT [PK_ClientSources] PRIMARY KEY CLUSTERED 
(
    [SocialTypeID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]    
GO

ALTER TABLE [dbo].[ClientSocialTypes]  WITH CHECK ADD  CONSTRAINT [FK_ClientSocialTypes_Clients] FOREIGN KEY([ClientID])
REFERENCES [dbo].[Clients] ([ClientID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[ClientSocialTypes] CHECK CONSTRAINT [FK_ClientSocialTypes_Clients]
GO

ALTER TABLE [dbo].[ClientSocialTypes]  WITH CHECK ADD  CONSTRAINT [FK_ClientSocialTypes_SocialTypeClasses] FOREIGN KEY([SocialTypeClassID])
REFERENCES [dbo].[SocialTypeClasses] ([SocialTypeClassID])
GO

ALTER TABLE [dbo].[ClientSocialTypes] CHECK CONSTRAINT [FK_ClientSocialTypes_SocialTypeClasses]
GO

ALTER TABLE [dbo].[ClientSocialTypes] ADD  CONSTRAINT [DF_ClientSocialTypes_SocialTypeClassID]  DEFAULT ((1)) FOR [SocialTypeClassID]
GO

ALTER TABLE [dbo].[ClientSocialTypes] ADD  CONSTRAINT [DF_ClientSocialTypes_TagCount]  DEFAULT ((0)) FOR [TagCount]
GO

ALTER TABLE [dbo].[ClientSocialTypes] ADD  CONSTRAINT [DF_ClientSocialTypes_HasTrackedURL]  DEFAULT ((0)) FOR [URLID]
GO

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

¢蛋碎的人ぎ生 2024-10-09 22:06:12

有两个不同的索引对话框。一个古老的可怕的可怕的,和一个新的(刚刚发现它),实际上可以让你改变这些事情。

旧的可怕的一个

  • 右键单击​​主表列表中的一个表
  • 单击“设计”
  • 右键单击​​列列表并选择“索引/键”

这不允许您更改包含的列。

NEW NICE ONE

  • 展开主表列表中的表以显示“Columns”、“Keys”、“Constraints”、“Triggers”等文件夹
  • 展开 Indexes 文件夹
  • Right单击Indexes文件夹中的New Index
  • 右键单击现有索引,然后单击Properties编辑现有索引

这个新的对话框允许您执行更多操作,我对微软让旧的保持活力以及我花了很长时间才发现它感到有点失望。

There's TWO different index dialogs. An ancient horrible awful one, and a new (only just discovered it) one that actually lets you change these things.

OLD HORRIBLE ONE

  • Right click on a table in your main tables list
  • Click 'Design'
  • Right click on the list of columns and select 'Indexes/Keys'

This doesn't let you change included columns.

NEW NICE ONE

  • Expand the table in your main tables list to show the 'Columns', 'Keys', 'Constraints', 'Triggers' etc folders
  • Expand the Indexes folder
  • Right click Indexes folder for New Index
  • Right click existing index and click Properties to edit an existing index

This newer dialog allows you to do a lot more and I'm kind of disappointed in Microsoft for keeping the old one alive and for how long it's taken me to discover it.

凉世弥音 2024-10-09 22:06:12

事实证明,在完整版本的 SQL Server 中,该选项也是灰色的。在 SSMS 中,使用对象资源管理器(而不是设计器)导航到 {database_name} >表> {表名}>用于管理包含的索引的索引。

It turns out this is grayed out in the full version of SQL Server too. In SSMS, use the Object Explorer (not the Designer) to navigate to {database_name} > Tables > {table_name} > Indexes to manage indexes that have includes.

贱贱哒 2024-10-09 22:06:12

该索引实际上可能是唯一约束(使用 CREATE/ALTER TABLE)而不是使用 CREATE INDEX 创建的索引。唯一约束不允许包含。

这非常令人困惑......为索引/键条目或表生成一个脚本,您将能够确认。

编辑:

  • 当您单独创建索引时,您必须刷新对象资源管理器

  • 您在不同的架构中是否有 2 个 SocialType 表? (例如dbo.SocialType[domain\myuser].SocialType)。如果您未在 DDL 语句中指定架构,则可能会发生这种情况。

The index may actually be a unique constraint (using CREATE/ALTER TABLE) rather than an index created using CREATE INDEX. Unique constraints don't allow INCLUDEs.

It's quite confusing... generate a script for the index/key entry or table and you'll be able to confirm.

Edit:

  • When you create the index separately you have to refresh Object Explorer

  • Do you have 2 SocialType tables in different schemas? (eg dbo.SocialType and [domain\myuser].SocialType). This can happen if you don't specify the schema in DDL statements.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文