1.10进制转16进制
Postgres里面有一个内置的10进制转16进制的函数:to_hex(int)/to_hex(bigint)

[postgres@localhost ~]$ psql
Password:
psql (9.1.3)
Type "help" for help. postgres=# select to_hex(9);
to_hex
--------
9
(1 row) postgres=# select to_hex(17);
to_hex
--------
11
(1 row) postgres=# select to_hex(31);
to_hex
--------
1f
(1 row) postgres=# select to_hex(255);
to_hex
--------
ff
(1 row) postgres=# select to_hex(256);
to_hex
--------
100
(1 row)

2.16进制转10进制
没有内置的,参考网上的一个例子

postgres=# CREATE FUNCTION
hex_to_dec(in_hex TEXT)
RETURNS INT
IMMUTABLE STRICT LANGUAGE sql AS
$body$
SELECT CAST(CAST(('x' || CAST($1 AS text)) AS bit(8)) AS INT);
$body$;
CREATE FUNCTION
postgres=# select hex_to_dec('1f');
hex_to_dec
------------
31
(1 row) postgres=# select hex_to_dec('ff');
hex_to_dec
------------
255
(1 row) postgres=# select hex_to_dec('fe');
hex_to_dec
------------
254
(1 row) postgres=# select hex_to_dec('09');
 hex_to_dec 
------------
          9
(1 row) postgres=# select hex_to_dec('11');
hex_to_dec
------------
17
(1 row)

最新文章

  1. css3 linear-gradient实现页面加载进度条效果
  2. PL/SQL 循环结构
  3. [BTS] BizTalk host BizTalkServerApplication throttled because DatabaseSize exceeded the configured throttling limit.
  4. Shopping(SPFA+DFS HDU3768)
  5. 2016年10月21日 星期五 --出埃及记 Exodus 19:5
  6. eclipse提交hadoop集群跑程序
  7. 十、装饰(Decorator)模式 --结构模式(Structural Pattern)
  8. http概览
  9. redux三个基本原则
  10. Haoop MapReduce 的Partition和reduce端的二次排序
  11. 在Kubernetes集群中使用calico做网络驱动的配置方法
  12. Python源码剖析之准备工作
  13. python 使用 PIL 和 matplotlib 获取图片像素点处理之后再写入
  14. 在香港用什么软件可以唱歌?香港K歌app推荐
  15. eclipse 假死
  16. Android 异步加载数据 AsyncTask异步更新界面
  17. 删除 AP 发票相关脚本
  18. rman 中遇到 ORA-01861
  19. 读《我是IT小小鸟》有感
  20. 【codeforces 528D】 Fuzzy Search

热门文章

  1. python模块/导入模块
  2. Go 每日一库之 go-carbon,优雅的golang日期时间处理库
  3. js逆向之补环境常用代码
  4. prometheus-添加监控linux服务器
  5. 【架构设计】保持简单轻量设计的三个原则——DRY,KISS, YAGNI
  6. [python] ​Python数据序列化模块pickle使用笔记
  7. vivo 实时计算平台建设实践
  8. 高并发解决方案orleans实践
  9. 软件安装——tortoiseGit安装和配置
  10. Codeforces Gym 104059B - Breeding Bugs