I have a database, and I need to know the default encoding for the database. I want to get it from the command line.
A programmatic solution:
SELECT pg_encoding_to_char(encoding) FROM pg_database WHERE datname = 'yourdb';