How do you change the character encoding of a postgres database?

后端 未结 5 1400
我在风中等你
我在风中等你 2020-11-29 16:26

I have a database that was set up with the default character set SQL_ASCII. I want to switch it to UNICODE. Is there an easy way to do that?

5条回答
  •  死守一世寂寞
    2020-11-29 16:52

    Daniel Kutik's answer is correct, but it can be even more safe, with database renaming.

    So, the truly safe way is:

    1. Create new database with the different encoding and name
    2. Dump your database
    3. Restore dump to the new DB
    4. Test that your application runs correctly with the new DB
    5. Rename old DB to something meaningful
    6. Rename new DB
    7. Test application again
    8. Drop the old database

    In case of emergency, just rename DBs back

提交回复
热议问题