gvenzl / oci-oracle-xe

Build scripts for Oracle Database XE container/docker images
Apache License 2.0
270 stars 76 forks source link

question: how do I create a database with character set CL8MSWIN1251? #208

Closed guai closed 1 year ago

guai commented 1 year ago

Hi Can anybody provide an example init script creating a database with CL8MSWIN1251 character set? I'm not a DBA so neither I managed to change the charset of the XEPDB1 nor create a new database.

gvenzl commented 1 year ago

Hey @guai,

The character set of the database is defined at the time of database creation. These images already include a created database and use UTF-8 Unicode as the character set which can represent any character set in the world.

The only way to create a new database with a different character set would be to use the -full image, extend it by removing the database and creating a new one with the desired character set, and then save that work as a new image or similar. But then again, the database inside the container is already in UTF-8, so technically there should be no reason to have a database with CL8MSWIN1251, you can simply set your client character set to that and Oracle will do the conversion from and to UTF-8 between the database and the client for you.

Thanks,

guai commented 1 year ago

Hi, @gvenzl. Thanks for the detailed explanation.

I think I managed to do so in my own fork. So, everybody with the same problem welcome to check it out.

I have a lot of legacy DDL scripts in some of which column sizes are defined in bytes not in chars and the data won't just fit because with UTF8 one need twice as many bytes to store the same Cyrillic string.

I'm not sure if I did everything right but it seems to work.

gvenzl commented 1 year ago

Ah I see, that makes sense. And I assume changing these DDL scripts isn't an option?

I looked at your fork, you got it right by changing the CHARSET configuration parameter before creating the database. :)

Thanks a lot for using these scripts!