- Via the
SHOW SERVER_ENCODING
command inpsql
, e.g., assuming the database isfoodb
,foodb=> SHOW SERVER_ENCODING
- Use a SQL query on
pg_database
, e.g., assuming the database isfoodb
,foodb=> SELECT pg_encoding_to_char(encoding) FROM pg_database WHERE datname = 'foodb';
- Use a SQL query the
information_schema
, e.g., assuming the database isfoodb
,foodb=> SELECT character_set_name FROM information_schema.character_sets WHERE default_collate_catalog='foodb'
In the above, the 3rd method is portable across most relational database systems since
information_schema
is a standard.