Jump to: navigation, search

PostgreSQL ENCODE

From w3cyberlearnings

Contents

Postgresql encode

Encoded binary data into textual representation.

Syntax encode

encode(text,format);

Format

base64,hex, escape. (Escape is outputs null bytes as \000 and doubles backslashes).

Example 1

test2=# SELECT encode('apple','base64');
  encode  
----------
 YXBwbGU=
(1 row)

Example 2

test2=# SELECT encode('apple','escape');
 encode 
--------
 apple
(1 row)

Example 3

test2=# SELECT encode('apple','hex');
   encode   
------------
 6170706c65
(1 row)

Example 4

postgres=# SELECT ENCODE(E'140\\000\\001','base64');
  encode  
----------
 MTQwAAE=
(1 row)

Related Links


Navigation
Web
SQL
MISC
References