带您了解Oracle文本函数

数据库 Oracle
Oracle数据库提供了很多函数供我们使用,下面为您介绍的Oracle函数是文本函数,如果您对此方面感兴趣的话,不妨一看。

Oracle文本函数使我们常用的函数,下面就为您介绍几种Oracle文本函数的用法,供您参考学习,希望可以让您对Oracle文本函数有更深的认识。

(1)UPPER、LOWER和INITCAP

这三个函数更改提供给它们的文体的大小写。

select upper(product_name) from product;

select lower(product_name) from product;

select initcap(product_name) from product;
函数INITCAP能够整理杂乱的文本,如下:

select initcap(‘this TEXT hAd UNpredictABLE caSE’) from dual;
(2)LENGTH

求数据库列中的数据所占的长度。

select product_name,length(product_name) name_length

from product

order by product_name;
(3)SUBSTR

取子串,格式为:

SUBSTR(源字符串,起始位置,子串长度);

create table item_test(item_id char(20),item_desc char(25));

insert into item_test values(‘LA-101’,’Can, Small’);

insert into item_test values(‘LA-102’,’Bottle, Small’);

insert into item_test values(‘LA-103’,’Bottle, Large’);
取编号:

select substr(item_id,4,3) item_num,item_desc

from item_test;
(4)INSTR

确定子串在字符串中的位置,格式如下:

INSTR(源字符串,要查找的字符串,查找起始位置)

select instr(‘this is line one’,’line’,1) from dual;
其返回值为子串在源字符串中从起始位置开始***次出现的位置。上面例子的返回值为9。

select item_desc , instr(item_desc,’,’,1)

from item_test;
(5)LTRIM、RTRIM和TRIM

去除字符串左边的空格、去除字符串右边的空格、去除字符串左右两边的空格。

select ltrim(‘ abc def ‘) from dual;

以上就是Oracle文本函数的用法介绍。

 

 

 

【编辑推荐】

带您深入了解Oracle触发器

创建Oracle包的语法

Oracle过程和函数的区别

Oracle to_char函数的使用

Java调用Oracle函数的两种情况

责任编辑:段燃 来源: 互联网
相关推荐

2010-10-25 15:20:23

Oracle数据转换函

2010-10-25 17:13:08

oracle分组函数

2010-10-27 16:22:07

Oracle层次查询

2010-10-26 11:55:21

Oracle OS备份

2010-11-15 13:20:06

Oracle恢复结构

2010-10-25 09:39:43

Oracle FBI索

2010-10-29 15:37:51

Oracle物理结构

2010-11-15 10:40:58

Oracle启动参数

2010-10-28 13:20:50

ORACLE reso

2010-10-09 14:00:10

mysql CONCA

2010-10-29 10:56:46

ORACLE用户验证

2010-10-27 14:57:24

Oracle查询

2010-11-16 14:59:39

Oracle显式游标

2010-10-27 14:27:13

oracle查询语句日

2010-10-25 16:29:45

Oracle随机数产生

2010-10-25 11:51:05

Oracle单行字符串

2010-10-29 10:04:27

2010-11-16 09:55:12

Oracle分区索引

2010-11-15 15:44:11

Oracle文件系统

2010-10-29 14:57:12

Oracle归档模式
点赞
收藏

51CTO技术栈公众号