oracle查关时间操作
Oracle关于时间/日期的操作
1.日期时间间隔操作
当前时间减去7分钟的时间
Java代码
select sysdate,sysdate - interval '7' MINUTE from dual
select sysdate,sysdate - interval '7' MINUTE from dual
当前时间减去7小时的时间
Java代码
select sysdate - interval '7' hour from dual
select sysdate - interval '7' hour from dual
当前时间减去7天的时间
Java代码
select sysdate - interval '7' day from dual
select sysdate - interval '7' day from dual
当前时间减去7月的时间
Java代码
select sysdate,sysdate - interval '7' month from dual
select sysdate,sysdate - interval '7' month from dual
当前时间减去7年的时间
Java代码
select sysdate,sysdate - interval '7' year from dual
select sysdate,sysdate - interval '7' year from dual
时间间隔乘以一个数字
Java代码
select sysdate,sysdate - 8 *interval '2' hour from dual
select sysdate,sysdate - 8 *interval '2' hour from dual
2.日期到字符操作
Java代码
select sysdate,to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual
select sysdate,to_char(sysdate,'yyyy-mm-dd hh:mi:ss') from dual
select sysdate,to_char(sysdate,'yyyy-ddd hh:mi:ss') from dual
select sysdate,to_char(sysdate,'yyyy-mm iw-d hh:mi:ss') from dual
select sysdate,to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual
select sysdate,to_char(sysdate,'yyyy-mm-dd hh:mi:ss') from dual
select sysdate,to_char(sysdate,'yyyy-ddd hh:mi:ss') from dual
select sysdate,to_char(sysdate,'yyyy-mm iw-d hh:mi:ss') from dual
参考oracle的相关关文档(ORACLE901DOC/SERVER.901/A90125/SQL_ELEMENTS4.HTM#48515)
3. 字符到日期操作
Java代码
select to_date('2003-10-17 21:15:37','yyyy-mm-dd hh24:mi:ss') from dual
select to_date('2003-10-17 21:15:37','yyyy-mm-dd hh24:mi:ss') from dual
具体用法和上面的to_char差不多。
4. trunk/ ROUND函数的
相关文档:
1. linux下启动oracle
su - oracle
sqlplus /nolog
conn /as sysdba
startup
exit
lsnrctl start
exit
2. linux下关闭oracle
su - oracle
sqlplus /nolog
conn /as sysdba
shutdown immediate
exit
lsnrctl stop
exit
3、启动监听器
oracle@suse92:~> lsnrctl start
4、停止监听器
oracle@suse92:~ ......
一、安装(略)
服务器端
1、windows:(略)
2、linux:待续...
客户端
待续...
--包括配置--
二、登陆
......
应用数据库中记录中date列莫名其妙的出现了几个值为0000-00-00的数据。
更可怕的是如果将这样的记录进行读取成为varchar2后再to_date转换回去就会报错。
问题无从查起,只说一下最终同事搜索到的连接结果:http://www.hellodba.com/Doc/oracle_date_zero_bug.htm
看来的确是oracle的一个bug。
另外需要注意的是,在使用 ......
先看一段ORACLE官方文档
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96520/analysis.htm#25806:
FIRST/LAST Functions
The FIRST/LAST aggregate functions allow you to return the result of an aggregate applied over a set of rows that rank as the first or last with respect to a ......
Oracle中的to_date()函数
to_date()与24小时制表示法及mm分钟的显示:
一、在使用Oracle的to_date函数来做日期转换时,很多Java程序员也许会直接的采用“yyyy-MM-dd HH:mm:ss”的格式作为格式进行转换,但是在Oracle中会引起错误:“ORA 01810 格式代码出现
&nbs ......