4
SELECT datname, pg_encoding_to_char(encoding) 
FROM pg_database;

…lists all the databases, each with its encoding type.

However, I am trying to find out what are all the encoding types available in the PostgreSQL server. Can I query for all available encoding types?

Or are the only encoding types ever available listed in Chapter 23.3 Character Set Support?

3

Or are the only encoding types ever available listed in Chapter 23.3 Character Set Support?

Yes. You can see the full list in the source code, if you insist

That said, it's highly abnormal to use any of these encoding except UTF-8 as an internal storage format. Unicode should support all of the useful characters in all of the other encodings. If you find UTF-8 acceptable, the only purpose these other encoding serve is to eliminate the need to create an ETL script for the COPY statement.

  • 2
    Right, I don't think it's exposed by any view/table, and information_schema.character_sets only shows the current DB's charset. – Craig Ringer Jul 26 '17 at 7:06
  • Thanks for the answer. Is there a way to get default encoding type set at the time of initdb? – Ashwin kumar Jul 26 '17 at 8:51
  • If no -E or --encoding option is given, initdb attempts to determine the appropriate encoding to use based on the specified or default locale. – Evan Carroll Jul 26 '17 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.