明天的明天 永远的永远 未知的一切 我与你一起承担 ??

是非成败转头空 青山依旧在 几度夕阳红 。。。
  博客园  :: 首页  :: 管理

postgresql 字符串转整数 int、integer

Posted on 2023-06-30 12:16  且行且思  阅读(2601)  评论(0编辑  收藏  举报

postgresql 字符串转整数 int、integer

 

--把'1234'转成整数

select cast('1234' as integer ) ;

--用substring截取字符串,从第8个字符开始截取2个字符:结果是12

select cast(substring('1234abc12',8,2) as integer)

---使用to_number函数来转换成整数

---to_number(text, text)  返回的类型 numeric     把字串转换成numeric   to_number('12,454.8-', '99G999D9S')

select to_number('12121','999999999')