How can I directly view blobs in MySQL Workbench

前端 未结 12 1835
一整个雨季
一整个雨季 2021-01-30 19:31

I\'m using MySQL Workbench CE 5.2.30 CE / Rev 6790 . When execute the following statement:

SELECT OLD_PASSWORD(\"test\")

I only get back a nice

相关标签:
12条回答
  • 2021-01-30 20:18

    NOTE: The previous answers here aren't particularly useful if the BLOB is an arbitrary sequence of bytes; e.g. BINARY(16) to store 128-bit GUID or md5 checksum.

    In that case, there currently is no editor preference -- though I have submitted a feature request now -- see that request for more detailed explanation.

    [Until/unless that feature request is implemented], the solution is HEX function in a query: SELECT HEX(mybinarycolumn) FROM mytable.


    An alternative is to use phpMyAdmin instead of MySQL Workbench - there hex is shown by default.

    0 讨论(0)
  • 2021-01-30 20:19

    there is few things that you can do

    SELECT GROUP_CONCAT(CAST(name AS CHAR))
    FROM product
    WHERE  id   IN (12345,12346,12347)
    

    If you want to order by the query you can order by cast as well like below

    SELECT GROUP_CONCAT(name ORDER BY name))
    FROM product
    WHERE id   IN (12345,12346,12347)
    

    as it says on this blog

    http://www.kdecom.com/mysql-group-concat-blob-bug-solved/

    0 讨论(0)
  • 2021-01-30 20:20

    Perform three steps:

    1. Go to "WorkBench Preferences" --> Choose "SQL Editor" Under "Query Results": check "Treat BINARY/VARBINARY as nonbinary character string"

    2. Restart MySQL WorkBench.

    3. Now select SELECT SUBSTRING(BLOB<COLUMN_NAME>,1,2500) FROM <Table_name>;

    0 讨论(0)
  • 2021-01-30 20:21

    SELECT *, CONVERT( UNCOMPRESS(column) USING "utf8" ) AS column FROM table_name

    0 讨论(0)
  • 2021-01-30 20:26

    casting works, but it is a pain, so I would recommend using spioter's method unless you are using a lot of truly blob data.

    SELECT CAST(OLD_PASSWORD("test") AS CHAR)
    

    You can also cast as other types, and even restrict the size, but most of the time I just use CHAR: http://dev.mysql.com/doc/refman/5.5/en/cast-functions.html#function_cast

    0 讨论(0)
  • 2021-01-30 20:26

    Work bench 6.3
    Follow High scoring answer then use UNCOMPRESS()

    (In short:
    1. Go to Edit > Preferences
    2. Choose SQL Editor
    3. Under SQL Execution, check Treat BINARY/VARBINARY as nonbinary character string
    4. Restart MySQL Workbench (you will not be prompted or informed of this requirement).)

    Then

    SELECT SUBSTRING(UNCOMPRESS(<COLUMN_NAME>),1,2500) FROM <Table_name>;
    

    or

    SELECT CAST(UNCOMPRESS(<COLUMN_NAME>) AS CHAR) FROM <Table_name>;
    

    If you just put UNCOMPRESS(<COLUMN_NAME>) you can right click blob and click "Open Value in Editor".

    0 讨论(0)
提交回复
热议问题