문제

I have to change my column data type and it is indexed. Altering the column giving me error that I need to drop the index, disabling won't work.

The question is how am I going to drop and recreate the exact index automatically? I can drop them but I have got no idea how I will be recreating them.

Cheers

도움이 되었습니까?

해결책

What DBMS are you using? Some DB Management Systems have the ability to script their database objects, but the commands differ between them.

If you can create a script, you'd do so, drop the index, change the field's datatype, save, then run the script to re-create the index.

If you can't create a script for your index with your particular DBMS, you'll have to write down all the relevant fields and settings by hand, then drop the index, change the field's datatype, save, then manually recreate the index from your notes.

다른 팁

One way to do this would be to create your new index field then do an update query like:

UPDATE yourTable
SET newIdx = oldIdx

Then once the new index is filled just set it as the index field and remove the old field.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top