Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display blob value using x'abc' binary string literal syntax?

Tags:

sqlite

You can easily enter a blob value using the x'abc' syntax, but is there a way to display it that way too? As shown below, selecting directly, or implicitly converting to a string using concatenation doesn't work, and shows garbage (Windows DOS prompt here).

sqlite> create table blobs (uid blob); sqlite> insert into blobs values (x'0123456789abcdef0123456789abcdef'); sqlite> select * from blobs; ☺#Egë½═∩☺#Egë½═∩ sqlite> select ''||uid from blobs; ☺#Egë½═∩☺#Egë½═∩ 

I'd like the select to display:

x'0123456789abcdef0123456789abcdef' 

Thanks, --DD

like image 830
ddevienne Avatar asked Jun 24 '09 16:06

ddevienne


1 Answers

select quote(uid) from blobs 

returns:

X'0123456789ABCDEF0123456789ABCDEF' 

and if you really need it in lowercase, you can use:

select lower(quote(uid)) from blobs 
like image 173
Mark Rushakoff Avatar answered Oct 10 '22 21:10

Mark Rushakoff