Inserting text string with hex into PostgreSQL as a bytea

前端 未结 5 2007
抹茶落季
抹茶落季 2020-12-13 05:50

I have a text file with several strings of hex in it:

013d7d16d7ad4fefb61bd95b765c8ceb
007687fc64b746569616414b78c81ef1

I would like to sto

5条回答
  •  天命终不由人
    2020-12-13 06:39

    More and sundry options:

    -- how to insert the string "123[a char of value zero]abc456"
    insert into mytable (testcol) values decode(E'123\\000abc456', 'escape');
    
    -- how to insert in base64: insert string "abc456"
    insert into mytable (testcol) values decode('YWJjNDU2', 'base64');
    

提交回复
热议问题