ORACLE函数使用
来源:互联网 发布:apache json解析 编辑:程序博客网 时间:2024/05/07 15:22
--如果WARE_ID 没有数据,则为1
SELECT nvl(a.WARE_ID,1) FROM DTF_TEST a;
--移动表到哪个分区 tablename 表名 new_name 分区名--
alter table tablename move
TABLESPACE new_name
Storage(initial 50M next 50M
pctincrease 0 pctfree 10 pctused 50 initrans 2) NOLOGGING;
--移动分区的语法
alter table tablename move (partition partname)
[update global indexes]
--如果为空 就不拼接--
select concat(WARE_ID,'88888888')||'转23' 丁腾飞电话 from DTF_TEST;
--首字母大写
select initcap(WARE_NAME) 大写 from DTF_TEST;
--返回字符串,并将所有的字符小写
select lower('AaBbCcDd') 小写 from dual;
--返回字符串,并将所有的字符大写
select upper('AaBbCcDd') 大写 from dual;
--LTRIM 删除左边出现的字符串
--RTRIM 删除右边出现的字符串
select ltrim(rtrim(' gao qian jing ',' '),' ') from dual;
--取子字符串,从start开始,取count个 08888888
select substr('13088888899',3,8) from dual;
--string 希望被替换的字符或变量
--s1 被替换的字符串
--s2 要替换的字符串
select replace('he love you','he','i') from dual;
--对给定的数字取整数
select floor(2345.67) from dual;
--四舍五入--
SELECT ROUND(1.56), ROUND(1.56,1), ROUND(12.34, -2) FROM dual
NVL NVL(A,B) 如果A是空,那么返回B 如果A不是空,返回A自己
NVL2 NVL2(A,B,C) 如果A不是空,则是B 如果A是空,则返回C
-----------------
select nvl(0,f()) from dual; 0不是空,所以仍然等于0 实际上,仍然触发了F() 也就是NVL里的所有表达式,不管是否满足,都必须执行
select nvl2(0,'not null',f()) from dual; 0不是空,所以直接返回NOT NULL 仍然执行了f() 也就是NVL和NVL2里的任何表达式,都必须执行
-----------------
select nvl2(0,'not null','null') from dual; 0如果不是空,显示第2个表达式"not null"
select coalesce(0,f()) from dual; coalesce(0,f())是显示第1个非空表达式,0就是非空,那f()会执行吗? 跟NVL一样,也强制执行了f() coalesce 9I会计算F() 10G的不计算F()
-----------------
select coalesce(null,1,2,3,4) from dual; coalesce(null,1,2,3,4)是返回第一个非空的表达式 这里第一个非空是1
select decode(0,0,'不执行f()',f()) from dual;只执行满足的表达式
select decode( i, 5, 'five', 6, 'six', 'Else I just don''t know!' ) from t; 4,5,6 而4没列在DECODE中
所以显示Else I just don''t know!
//如果有符合的数据,就填充,没有,则,dd
SELECT DECODE(t.a,1,'one',2,'two',3,'three','dd') a FROM t;
//求出最大值和最小值的时候,如果是单个SQL语句去取,则需要扫描整个索引
//如果我们用两个SQL子句并行去取一个MAX,一个MIN
1.select min(created),max(created) from big_table;
//效率更好
2.select min(created), max(created)
from (
select min(created) created from big_table
union all
select max(created) created from big_table
)
//所有数据中,每行最大的数据
select t.*, greatest( a,b,c) row_max from t;
select nvl2(0,'not null','null') from dual;
select coalesce(0,f()) from dual;
- Oracle to_char函数使用
- ORACLE函数使用
- oracle函数简单使用
- Oracle 函数使用
- oracle中的函数使用
- oracle decode()函数使用
- Oracle to_date()函数使用
- oracle分析函数使用
- Oracle evl 函数使用
- ORACLE 函数使用大全
- Oracle 正则函数使用
- Oracle bitand( )函数使用
- oracle 函数使用
- oracle排名函数使用
- oracle分析函数使用
- ORACLE--COUNT()函数使用
- Oracle数据库函数使用
- Oracle函数的使用
- Linux下读写芯片的I2C寄存器
- 创新三要素
- 新博客开通
- jQuery 同步提交演示
- WCF-省略DataContract标记
- ORACLE函数使用
- 云计算的两大误区:市场和技术
- stat结构体 详解
- oracle表连接方式
- "perl: warning: Setting locale failed."的解决
- const
- linux2.6.29 CFS调度详细分析
- AIR版的通讯簿(五)
- Zend Framework教程-Zend_Helpers-动作助手(Zend_Controller_Action_Helper)概述