Board index » delphi » changing character set

changing character set

I have a large database in a library, character set is set to none.
I'm brasilian and I need change it to WIN1252 and use collate PXW_INTL850

Are there how do this and preserve the data ?
Or will I need create a new gdb with apropriate character set  and import
the data?

thanks to all

Enio Bueno

 

Re:changing character set


Enio,

Unfortunately, you will have to recreate the database with
the new character set and import the data from the hold
database. IB has no ability to change character sets on the
fly.

You can save a bit of time and frustration, however, by
creating domains with the collation order and using the
domains on the table definitions. This is easier than
applying the collation order directly to the table creates.

For example, suppose you commonly use two lengths in your
character-based fields: VarChar(20) and VarChar(60). Your
domains would look like this:

CREATE DOMAIN shortname
    AS VARCHAR(20) COLLATE EN_US;
CREATE DOMAIN longname
    AS VARCHAR(60) COLLATE EN_US;

Then use the domain names in the table definitions.

Good luck.

Phil Cain

Re:changing character set


Not sure what a result would be, but you can execute
ALTER TABLE table ALTER COLUMN col TYPE <new type> and a new type might
include a character set

Kris

Quote
Philip Cain wrote:
>Enio,

>Unfortunately, you will have to recreate the database with
>the new character set and import the data from the hold
>database. IB has no ability to change character sets on the
>fly.

>You can save a bit of time and frustration, however, by
>creating domains with the collation order and using the
>domains on the table definitions. This is easier than
>applying the collation order directly to the table creates.

>For example, suppose you commonly use two lengths in your
>character-based fields: VarChar(20) and VarChar(60). Your
>domains would look like this:

>CREATE DOMAIN shortname
>    AS VARCHAR(20) COLLATE EN_US;
>CREATE DOMAIN longname
>    AS VARCHAR(60) COLLATE EN_US;

>Then use the domain names in the table definitions.

>Good luck.

>Phil Cain

Re:changing character set


Kris,

Quote
>Not sure what a result would be, but you can execute
>ALTER TABLE

You cannot change a character set by using alter table, but
my apologies to Enio for giving what may be outdated
information.

In IB6 it is possible to mix character sets in a database.
You set a default charset or none at creation time;
individual columns and domains can be set to other charsets;
you can even override the default charset at login time with
the SET NAMES statement.

I also saw a reference to CharSetName in the SELECT
statement, but I'm not sure how it is used.

None of this was available before IB6, AFAIK.

This changes what Enio has to do. I still think that some
conversion is necessary but the job may not be so severe as
it once would have been. I can't be more specific because
I've never worked with these features.

There is one caveat. When a column is defined with one
charset, you cannot move data from it to another column with
a different charset (except that data can be moved freely to
and from a column with no charset). This applies even though
the data in the two columns may be identical!

Phil Cain

Other Threads