Skip to content

Instantly share code, notes, and snippets.

@flug
Forked from jpetitcolas/gist:5967887
Last active October 31, 2019 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flug/78713cda69bfb8126fb308bc716d1cc8 to your computer and use it in GitHub Desktop.
Save flug/78713cda69bfb8126fb308bc716d1cc8 to your computer and use it in GitHub Desktop.
[PostGreSQL JSON field] Encode/decode a base64 encoded string in PostGreSQL #PostGreSQL
-- Decoding
SELECT CONVERT_FROM(DECODE(field, 'BASE64'), 'UTF-8') FROM table;
-- Encoding
SELECT ENCODE(CONVERT_TO(field, 'UTF-8'), 'base64') FROM table;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment