2017-04-10 19 views

回答

9

由於是VARCHAR而你正在增加尺寸,那麼只需ALTER TABLE ... ALTER COLUMN ...就足夠了。

The data type of columns included in an index cannot be changed unless the column is a varchar, nvarchar, or varbinary data type, and the new size is equal to or larger than the old size.

否則,您將刪除索引,更改列,然後添加索引(es)。

要知道,雖然SQL Server的maximum index key size是(較新的版本或1700)900,所以即使ALTER會成功,未來 數據超過900長度限制的INSERT將失敗,錯誤:

Msg 1946, Level 16, State 3, Line 13 
Operation failed. The index entry of length ... bytes for the index '...' exceeds the maximum length of 900 bytes. 
+0

感謝您的幫助:) –

-1

嗨下面是聲明。 看看它是否可以幫助你。

其在oracle中的一個例子。

create table emp (name varchar(200));

ALTER TABLE EMP MODIFY NAME VARCHAR(800);

0

嘗試此MSSQL:

drop index person.idx_pers_fullname 
ALTER table person alter COLUMN pers_firstname nvarchar(8000) 
create index idx_pers_fullname on person(pers_firstname) 
相關問題