2012年2月16日星期四

Any easy way to change column length like varchar 30 to varchar 100?

I would like to increase the length of the column from
LOCNumber VARCHAR(30) DEFAULT ''

to
LOCNumber VARCHAR(100) DEFAULT ''

without losing any data currently stored in the field.

And it has an index on it defined as
CREATE INDEX LOCIndex ON BookData(LOCNumber)

Thanks for any help.On 31 Jan 2005 07:05:21 -0800, sdowney717@.msn.com wrote:

>I would like to increase the length of the column from
>LOCNumber VARCHAR(30) DEFAULT ''
>to
>LOCNumber VARCHAR(100) DEFAULT ''
>without losing any data currently stored in the field.

Hi sdowney,

Just use ALTER TABLE:

ALTER TABLE BookData
ALTER COLUMN LOCIndex varchar(100)

No need to re-specify the default - it won't be changed.

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)|||That works well, thanks very much
Do you know how to do this with MySQL as well?|||Found it, you use this
ALTER TABLE BookData MODIFY COLUMN LOCNumber varchar(100)

没有评论:

发表评论