1
我有以下表结构:如何解决“最大允许密钥长度为900字节”。
CREATE TABLE [dbo].[Formats]
(
[caption_id] [nvarchar](512) NOT NULL,
Formats_exist BIT NOT NULL
)
Result-: 1 row created
ALTER TABLE [dbo].[Formats]
ADD CONSTRAINT [pk__formats]
PRIMARY KEY CLUSTERED ([caption_id] ASC);
Result-: 1 row created
CREATE TABLE [dbo].[Signature]
(
[caption_id] [nvarchar](512) NOT NULL,
[signature_id] [int] NOT NULL
)
Result-: 1 row created
ALTER TABLE [dbo].[Signature]
ADD CONSTRAINT [pk__signatures]
PRIMARY KEY CLUSTERED ([caption_id] ASC,[signature_id] ASC);
Result-:
Msg 1944, Level 16, State 1, Line 1
Index 'pk__signatures' was not created. This index has a key length of at least 1028 bytes. The maximum permissible key length is 900 bytes.
Msg 1750, Level 16, State 0, Line 1
Could not create constraint. See previous errors.
为什么我收到错误上面的主键,而我不是第一个收到错误虽然是nvarchar(512)
和它是超过900字节。
任何人都可以帮助我解决这个问题吗?