Gbase 8s内置函数之字符串函数

Gbase 8s的内置函数包含标量函数、聚合函数、窗口函数以及其他的函数。

其中标量函数又包含数学函数、字符串函数、日期函数。

本次介绍字符串函数及其使用例句:

CONCAT

select concat('Hello', 'World') as f_concat from dual;

TRIM/LTRIM/RTRIM

select f_message,

    octet_length(f_message) as f_len1,

    octet_length(trim(f_message)) as f_len2,

    octet_length(ltrim(f_message)) as f_len3,

    octet_length(rtrim(f_message)) as f_len4

from (select ' Hello world    ' as f_message from dual) t;

 

SUBSTR/SUBSTRB/SUBSTRING

select substr('abcdefg', 2, 3) as f_substr from dual;

INSTR

select instr('How are you?', 'o', 1, 1) as f_instr1, instr('How are you?', 'o', 1, 2) as f_instr2 from dual;

ASCII

select ascii('Hello') as f_ascii1, ascii('world') as f_ascii2, ascii('小王') as f_ascii3 from dual;

select ascii('小') as f_ascii1, ascii('王') as f_ascii2, ascii('小王') as f_ascii3 from dual;

REPLACE

select content, replace(content, 'reading', 'writing')  as f_replace

from

(select 'I like reading' as content from dual) t;

UPPER/LOWER

select upper('Hello World') as f_upper, lower('Hello World') as f_lower from dual;

LENGTH/OCTET_LENGTH/CHAR_LENGTH

select length('南大通用') as f_len11, length('南大通用:GBase') as f_len12 , octet_length('南大通用') as f_len21, octet_length('南大通用:GBase') as f_len22, char_length('南大通用') as f_len31, char_length('南大通用:GBase)') as f_len3 from dual;

REGEXP_REPLACE/REGEXP_SUBSTR/REGEXT_INSTR

select f_content, regexp_replace(f_content, '\d{11}', '<phone_number>') as f_template from (select '我的电话号码是13920656789,我家的邮编是300160。' as f_content from dual union all select '快递已经给您放小区菜鸟驿站了,有问题打电话18632145678。' as f_content from dual) t;

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

八珍豆腐

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值