When running sql script to view data on Cexplorer database, many times,I see binary data. for example, multi_asset.name, multi_asset.policy in the following query.
Is there any way to view these data in normal text?
Thanks very much.
Cardano Stack Exchange is a question and answer site for users and developers of the Cardano cryptocurrency ecosystem. It only takes a minute to sign up.
Sign up to join this communityThese fields are not in general "normal text". They might be normal text (eg ASCII) or they could also be UTF-8 or UTF-16 or any other encoding.
The most sensible way to view them is as hexadecimal and that is what the psql
command line does. Eg:
$ psql cexplorer
psql (14.5 (Debian 14.5-1), server 13.7 (Debian 13.7-0+deb11u1))
Type "help" for help.
cexplorer=# select * from multi_asset limit 1 ;
id | policy | name | fingerprint
----+------------------------------------------------------------+------------------+----------------------------------------------
1 | \x00000002df633853f6a47465c9496721d2d5b1291b8398016c0e87ae | \x6e7574636f696e | asset12h3p5l3nd5y26lr22am7y7ga3vxghkhf57zkhd
(1 row)
So it you want something that is guaranteed to be "normal text" you should use the fingerprint
field, which is Bech32 encoded.
in your case:
SELECT multi_asset.policy::text human_policy FROM ...
or
SELECT encode(multi_asset.name::bytea, 'escape'::text) human_name FROM ...