索引字节限制
SQL Server 中的索引键最大长度为 900 字节。如果索引超过 900 字节限制,会发生异常。要防止发生异常,请确保索引使用的数据值小于 900 字节。
以下是当索引大小超过 900 字节时发生异常的示例。
例如:
执行插入语句,索引大小超过 900 字节
wt.pom.DatastoreException: A SQL error has occurred for the statement
"INSERT INTO WTUser(classnameA2A2,updateCountA2,blob$entrySetadHocAcl,
disabled,
classnamekeydomainRef,idA3domainRef,entrySetadHocAcl,eventSet,inherited
Domain,name,repairNeeded,markForDeleteA2,updateStampA2,createStampA2,modify
StampA2,idA2A2) VALUES (’wt.org.WTUSER’,1,?,?,?,?,?,?,?,?,?,?,?,?,?)".
Database system message follows: Nested exception is: java.sql.SQLException:
[ptc][SQLServer JDBC Driver][SQLServer]Operation failed. The index entry of
length 2000 bytes for the index ’WTUser$COMPOSITE’ exceeds the maximum
length of 900 bytes.
例如:
执行更新语句,索引大小超过 900 字节
wt.pom.DatastoreException: A SQL error has occurred for the statement
"UPDATE WTUser SET blob$entrySetadHocAcl=?,disabled=?,classnamekey
domainRef=?,idA3domainRef=?,entrySetadHocAcl=?,eventSet=?,inherited
Domain=?,name=?,repairNeeded=?,markForDeleteA2=?,
updateStampA2=?,modifyStampA2=?,updateCountA2=updateCountA2+1 WHERE
((idA2A2 = ?) AND (updateCountA2 = ? ))" Database system message follows:
Nested Exception is: java.sql.SQLException: [ptc][SQLServer JDBC Driver]
[SQLServer]Operation failed. The index entry length of 2000 bytes for the
index ’WTUser$COMPOSITE’ exceeds the maximum length of 900 bytes.
另外,执行 create_ddl_wt.bat 文件时,可能会遇到警告。可以忽略这些警告。
例如:
运行 create_ddl_wt.bat 文件
Warning: message=[ptc][SQLServer JDBC Driver][SQLServer]Warning! The
maximum key length is 900 bytes. The index 'WTUser$COMPOSITE' has
maximum length of 4000 bytes. For some combination of large values,
the insert/update operation will fail. command=CREATE INDEX WTUser$
COMPOSITE ON WTUser(name)