0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

MySQLにバイナリ文字列で保存されたデータを見てわかる形で表示する

Last updated at Posted at 2021-02-18

概要

バイナリ文字列で保存されたデータをわかりやすくselectするための方法の備忘録。
実行環境はMySQL5.6

具体例

他のサービスと連携してログインできるようなテーブルUsersがあるとします。

カラム名 id name auth_type
データ型 int varchar(255) barbinary(255)

とりあえずselectして中身を見てみる

select * from Users;

image.png
...?

どうするか

cast関数で囲って変換しましょう

select id,name,cast(auth_type as char(255)) as auth_type from Users;

image.png

参考

ブラウザ上で実行できるsqlfiddleというサイトを利用してみました。
記事内で利用したクエリはこちら

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?