加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

PostgreSQL字符串处理

发布时间:2020-12-13 17:08:08 所属栏目:百科 来源:网络整理
导读:关于查找字符串 select position( 'hello' in 'test_sql' ) output : 0 select position( 'test' in 'test_sql' ) output : 1 故可用 position(str_1 in str_2) != 0 判断str_1是否是str_2的子串。 字符串与数字的相互转换 字符串-数字 to_number(block_id,'

关于查找字符串

select position('hello' in 'test_sql') output:0 select position('test' in 'test_sql') output:1 

故可用position(str_1 in str_2) != 0判断str_1是否是str_2的子串。


字符串与数字的相互转换

  • 字符串->数字

    to_number(block_id,'999999')cast(block_id as numeric),但前一句会限定的数字大小为10的5次方,即过大的数值会出问题,而后一句不会。

  • 数字->字符串

    cast(block_id as varchar)将数值型转为字符串型。


参考

  1. 9.4. 字符串函数和操作符
  2. 9.8. 数据类型格式化函数
  3. PostgreSQL 类型转换
  4. Postgres 中 to_char 格式化记录

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读