您的位置:首页 > 数据库 > Oracle

oracle 常用函数(substr,chr,ascii), select 'X'

2011-06-09 11:06 537 查看
/*oracle 常用函数, select 'X' */

/*

1.substr() 是oracle里面的字符串截取函数,第一个参数是要截取的字符串,

第二个参数是从字符串的下标开始截取,第三个参数是截取字符串的长度。

If position is 0, then it is treated as 1.

If position is positive, then Oracle counts from the beginning of string to find the first character.

If position is negative, then Oracle counts backward from the end of string.

If substring_length is omitted, then Oracle returns all characters to the end of string. If substring_length is less than 1, then a null is returned.

从以上片段可以说明三点

1. substr('xxx' ,1,2) 与 substr('xxx',0,2)没有区别;

2,如果参数为负数则从字符串后面开始取子串 如;substr('abc123',-2) = '12';

3.如果字符串为空,则返回空串;

2.chr(),ascii() 相互成为反函数

如;chr(65)=‘A’,ascii('A')= 65;

3. select 'X' from ‘XXX’这样执行效率会比较高一点。

因为有些时候我们只需要查看是否有记录就OK。而不是要把实际栏位值给查询出来。

如; select * from WHERE NOT EXISTS (SELECT 'X'from 'XXX');

4.length() 统计文本字符数,注;中文占一位

//ceil() 大于等于的一个整数 和 floor() 小于等于的一个整数

// power(m,n) //m的n次幂

//mod(m,n); //取余

sin() 正弦值

sqrt() 平方根

tan

//字符函数

concat('a','b');

initcap()将首字母大写

length(char) 用于返回字符串的长度

lower(char); 用于将字符串转换为小写格式

lpad(char1,n,char2); 用与在字符串char1 左端填充字符串

upper(char);//将字符串转换为大写

// sign(n); //检测数字的正负

*/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: