Subject Re: [firebird-support] regenerating indices
Author Milan Babuskov
martinknappe wrote:
> ive changed the collation in a couple of fields in my database; now as
> it happens, the collation used is still the old one.

How did you change it? AFAIK, Firebird doesn't have SQL command to do
that. You probably used some tool that modifies the system tables
directly, but that is (evidently) very error prone. I such cases it is
much safer to create a new column with desired collation, copy data to
it, drop the original column and then rename the new column to old name:

ALTER TABLE x ADD newcol VARCHAR(...) ... COLLATE ...etc.
UPDATE x SET newcol = oldcol;
ALTER TABLE x DROP oldcol;
ALTER TABLE x ALTER newcol TO oldcol;

If you have dependencies on that column, you can use FlameRobin's
"Generate rebuild script" option that creates the appropriate DROP and
CREATE statements to remove dependencies and to re-create them after
you're done changing the column.

Also, which Firebird version?

> when i create a fresh database with the new collation straight away,
> it works...do i somehow have to regenerate the indices if i change the
> collation AFTER data has been inserted? how do i do that?

Either DROP and CREATE index, or do this:

ALTER INDEX index_name INACTIVE;
ALTER INDEX index_name ACTIVE;

In FlameRobin, you can simply click on the icons on table's "Indices"
page and be done with it.


--
Milan Babuskov
http://swoes.blogspot.com/
http://www.flamerobin.org