oracle常用语法
2015-09-30 15:10
555 查看
一,输出
PL/SQL中: dbms_output.PUT_LINE(‘www’) ;
二,执行无参数存储过程:
PL/SQL中: call p_zy_home() ;
三,if elsif end if; 判断
if REG_MONEY >100000000 then
REGISTERED:=5;
elsif REG_MONEY >=10000000 then
REGISTERED:=3;
else
REGISTERED:=0;
end if;
四,Oracle中没有 if exists(…)
declare
v_cnt number;
begin
select count(*) into v_cnt from T_VIP where col=1;
if v_cnt = 0 then
dbms_output.put_line(‘无记录’);
end if;
end;
五,oracle如何得到64位的世界唯一随机数
declare
v_guid varchar2(64);
begin
v_guid:=sys_guid();
dbms_output.put_line(v_guid);
end ;
六,日期和字符转换函数用法(to_date,to_char)
select to_char(sysdate,’yyyy-mm-dd hh24:mi:ss’) as nowTime from dual; //日期转化为字符串
select to_char(sysdate,’yyyy’) as nowYear from dual; //获取时间的年
select to_char(sysdate,’mm’) as nowMonth from dual; //获取时间的月
select to_char(sysdate,’dd’) as nowDay from dual; //获取时间的日
select to_char(sysdate,’hh24’) as nowHour from dual; //获取时间的时
select to_char(sysdate,’mi’) as nowMinute from dual; //获取时间的分
select to_char(sysdate,’ss’) as nowSecond from dual; //获取时间的秒
PL/SQL中: dbms_output.PUT_LINE(‘www’) ;
二,执行无参数存储过程:
PL/SQL中: call p_zy_home() ;
三,if elsif end if; 判断
if REG_MONEY >100000000 then
REGISTERED:=5;
elsif REG_MONEY >=10000000 then
REGISTERED:=3;
else
REGISTERED:=0;
end if;
四,Oracle中没有 if exists(…)
declare
v_cnt number;
begin
select count(*) into v_cnt from T_VIP where col=1;
if v_cnt = 0 then
dbms_output.put_line(‘无记录’);
end if;
end;
五,oracle如何得到64位的世界唯一随机数
declare
v_guid varchar2(64);
begin
v_guid:=sys_guid();
dbms_output.put_line(v_guid);
end ;
六,日期和字符转换函数用法(to_date,to_char)
select to_char(sysdate,’yyyy-mm-dd hh24:mi:ss’) as nowTime from dual; //日期转化为字符串
select to_char(sysdate,’yyyy’) as nowYear from dual; //获取时间的年
select to_char(sysdate,’mm’) as nowMonth from dual; //获取时间的月
select to_char(sysdate,’dd’) as nowDay from dual; //获取时间的日
select to_char(sysdate,’hh24’) as nowHour from dual; //获取时间的时
select to_char(sysdate,’mi’) as nowMinute from dual; //获取时间的分
select to_char(sysdate,’ss’) as nowSecond from dual; //获取时间的秒
相关文章推荐
- 基于 Red Hat 的发行版 Oracle Linux 正式发布Oracle Linux 7.1
- Oracle Containers for J2EE远程安全漏洞(CVE-2014-0413)
- Oracle 10g R2不能使用EM的问题
- 表空间操作
- PreparedStatement中in子句的处理
- VMware下RedHat4.8_64位安装Oracle 10g RAC--简略脚本
- oracle sql日期比较
- 基于 Red Hat 的发行版 Oracle Linux 正式发布Oracle Linux 7.1
- OS block size和Oracle block size,查找OS Blocksize的方法
- oracle中创建数据库和表空间的几点总结
- 数据库自动备份脚本
- oracle的nvl函数的使用介绍
- 解决oracle用户连接失败的解决方法
- oracle的一些tips技巧
- Oracle 下的开发日积月累
- Oracle存储过程之数据库中获取数据实例
- Windows下ORACLE 10g完全卸载的方法分析
- plsql与tsql的语法不同
- Oracle 函数大全[字符串函数,数学函数,日期函数]第1/4页