I have a database, and I need to know the default encoding for the database. I want to get it from the command line.
From the command line:
psql my_database -c 'SHOW SERVER_ENCODING'
From within psql, an SQL IDE or an API:
psql
SHOW SERVER_ENCODING