Oracle 中的 TO_DATE 和 TO_CHAR 函数
oracle 中 TO_DATE 函数的时间格式,以 2008-09-10 23:45:56 为例
格式
说明
显示值
备注
Year(年):
yy
two digits(两位年)
08
yyy
three digits(三位年)
008
yyyy
four digits(四位年)
2008
Month(月):
mm
number(两位月)
09
mon
abbreviated(字符集表示)
9月
若是英文版, 则显示 sep
month
spelled out(字符集表示)
9月
若是英文版, 则显示 september
Day(日):
dd
number(当月第几天)
10
ddd
number(当年第几天)
254
dy
abbreviated(当周第几天简写)
星期三
若是英文版, 则显示 wed
day
spelled out(当周第几天全写)
星期三
若是英文版, 则显示 wednesday
ddspth
spelled out, ordinal twelfth
tenth
Hour(时):
hh
two digits(12小时进制)
11
hh24
two digits(24小时进制)
23
Minute(分):
mi
two digits(60进制)
45
Second(秒):
ss
two digits(60进制)
56
其他:
Q
digit(季度)
3
WW
digit(当年第几周)
37
W
digit(当月第几周)
2
说明:
12小时格式下时间范围为: 1:00:00 - 12:59:59(12 小时制下的 12:59:59 对应 24 小时制下的 00:59:59)
24小时格式下时间范围为: 0:00:00 - 23:59:59
1. 日期和字符转换函数用法(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
相关文档:
一、准备特殊数据
create table t_escape(s varchar2(50));
--show define -- define "&" (hex 26)
--show escape -- escape off
set define off
set escape on
insert into t_escape values('string&text');
insert into t_escape values('string\&text');
insert into t_escape values('st ......
ORACLE
CREATE OR REPLACE FUNCTION SETSTATE(OLDVALUE VARCHAR2, POS NUMBER, SVALUE VARCHAR2)
RETURN VARCHAR2
IS
RETURN_VALUE VARCHAR2 (20);
LEN NUMBER(8);
I NUMBER(8);
TEMP_VALUE VARCHAR2(1);
BEGIN
LEN := LENGTH(OLDVALUE);
IF POS > ......
容易得说,经过dbms_random包调用随机数的步骤大体有4种:
一、dbms_random.normal
这个函数不带参数,会回到normal distribution的一个number门类,之所以大抵随机数会在-一到一其间。
简略测试了一下子,发作100000次最大能到五上下:
SQL> declare
二 i number:=零;
三 j number:=零;
四 begin
五 for ......
oracle 默认隔离等级是:读已提交。
查询锁定,防止另外用户更新:
select * from books for update;
当前用户更新之后,另外用户可以更改。
01、表连接
假定from子句中从左到右两个表分别为A,B表。
内连接:选取A、B表的完全匹配的集合,两表交集:
select empno,ename,emp.deptno A,dept.deptno B,dname from emp ......
The following are number examples for the to_char function.
to_char(1210.73, '9999.9')
would return '1210.7'
to_char(1210.73, '9,999.99')
would return '1,210.73'
to_char(1210.73, '$9,999.00')
would return '$1,210.73'
to_char(21, '000099')
would return '000021'
The following is a list ......