6

I have the following databases

sudo -u postgres psql -c "\list"

                             List of databases
   Name    |  Owner   | Encoding | Collate | Ctype |   Access privileges   
-----------+----------+----------+---------+-------+-----------------------
 postgres  | postgres | LATIN1   | en_US   | en_US | 
 template0 | postgres | LATIN1   | en_US   | en_US | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
 template1 | postgres | LATIN1   | en_US   | en_US | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
(3 rows)

How can I change encoding from LATIN1 to UTF8 in the database template1 or template0?

1

2 Answers 2

4

Since you don't appear to have any actual data here, just shutdown and delete the cluster (server and set of databases) and re-create it. Which operating system are you using? The standard PostgreSQL command to create a new cluster is initdb, but on Debian/Ubuntu et al you'd typically use pg_createcluster

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

Although you can try to tweak the encodings, it's not recommended. Even though I suggested it in that linked question, if you had data with latin1 characters here, you'd need to recode them to utf-8.

Sign up to request clarification or add additional context in comments.

Comments

0

Just use:

update pg_database set encoding = pg_char_to_encoding('LATIN1') where datname = 'seguros'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.