PostgreSQL 16進数に変換する

PostgreSQL 16進数に変換する

PostgreSQLで、16進数に変換する手順を記述してます。「to_hex」に数値を指定することで可能です。

環境

  • OS Rocky Linux release 8.4 (Green Obsidian)
  • PostgreSQL 14.0
  • pgadmin4 6.16

手順

16進数に変換する場合は、「to_hex」を利用します。

to_hex(数値)

実際に、「15」を16進数に変換します。

SELECT    
    to_hex(12) AS "to_hex(12)",
    to_hex(13) AS "to_hex(13)",
    to_hex(14) AS "to_hex(14)",
    to_hex(15) AS "to_hex(15)",
    to_hex(16) AS "to_hex(16)",
    to_hex(17) AS "to_hex(17)";

実行結果

変換されていることが確認できます。