自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Oracle數(shù)據(jù)庫中時間處理

數(shù)據(jù)庫 Oracle
Oracle數(shù)據(jù)庫是一種應(yīng)用很廣泛的數(shù)據(jù)庫,Oracle數(shù)據(jù)庫性能比較好,操作簡單而且操作速度快,下文中將為大家講解Oracle數(shù)據(jù)庫中時間的處理方法。

Oracle數(shù)據(jù)庫中時間的處理:

4824小時的形式顯示出來要用HH24

select to_char(sysdate,'yyyy-MM-dd HH24:mi:ss') from dual;

select to_date('2005-01-01 13:14:20','yyyy-MM-dd HH24:mi:ss') from dual;

to_date() function

1.日期格式參數(shù) 含義說明

D 一周中的星期幾

DAY 天的名字,使用空格填充到9個字符

DD 月中的第幾天

DDD 年中的第幾天

DY 天的簡寫名

IW ISO標(biāo)準(zhǔn)的年中的第幾周

IYYY ISO標(biāo)準(zhǔn)的四位年份

YYYY 四位年份

YYY,YY,Y 年份的最后三位,兩位,一位

HH 小時,按12小時計

HH24 小時,按24小時計

MI 分

SS 秒

MM 月

Mon 月份的簡寫

Month 月份的全名

W 該月的第幾個星期

WW 年中的第幾個星期 1.日期時間間隔操作

當(dāng)前時間減去7分鐘的時間

select sysdate,sysdate - interval '7' MINUTE from dual

當(dāng)前時間減去7小時的時間

select sysdate - interval '7' hour from dual

當(dāng)前時間減去7天的時間

select sysdate - interval '7' day from dual

當(dāng)前時間減去7月的時間

select sysdate,sysdate - interval '7' month from dual

當(dāng)前時間減去7年的時間

select sysdate,sysdate - interval '7' year from dual

時間間隔乘以一個數(shù)字

select sysdate,sysdate - 8 *interval '2' hour from dual

2.日期到字符操作

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

參考o(jì)racle的相關(guān)關(guān)文檔(ORACLE901DOC/SERVER.901/A90125/SQL_ELEMENTS4.HTM#48515)

3. 字符到日期操作

select to_date('2003-10-17 21:15:37','yyyy-mm-dd hh24:mi:ss') from dual

具體用法和上面的to_char差不多。

4. trunk/ ROUND函數(shù)的使用

select trunc(sysdate ,'YEAR') from dual

select trunc(sysdate ) from dual

select to_char(trunc(sysdate ,'YYYY'),'YYYY') from dual

5.oracle有毫秒級的數(shù)據(jù)類型

--返回當(dāng)前時間 年月日小時分秒毫秒

select to_char(current_timestamp(5),'DD-MON-YYYY HH24:MI:SSxFF') from dual;

--返回當(dāng)前 時間的秒毫秒,可以指定秒后面的精度(最大=9)

select to_char(current_timestamp(9),'MI:SSxFF') from dual;

6.計算程序運行的時間(ms)

declare

type rc is ref cursor;

l_rc rc;

l_dummy all_objects.object_name%type;

l_start number default dbms_utility.get_time;

begin

for I in 1 .. 1000

loop

open l_rc for

'select object_name from all_objects '||

'where object_id = ' || i;

fetch l_rc into l_dummy;

close l_rc;

end loop;

dbms_output.put_line

( round( (dbms_utility.get_time-l_start)/100, 2 ) ||

' seconds...' );

end;

to_char() function

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 of valid parameters when the to_char function is used to convert a date to a string. These parameters can be used in many combinations.

Parameter Explanation

YEAR Year, spelled out

YYYY 4-digit year

YYY

YY

Y Last 3, 2, or 1 digit(s) of year.

IYY

IY

I Last 3, 2, or 1 digit(s) of ISO year.

IYYY 4-digit year based on the ISO standard

關(guān)于Oracle數(shù)據(jù)庫中時間的處理就為大家講解到這里,可能還不是很全面,以后有機會還會繼續(xù)為大家講解這方面的知識,希望對大家能夠有所幫助。 

責(zé)任編輯:迎迎 來源: 中國IT實驗室
相關(guān)推薦

2010-04-30 14:39:03

Oracle數(shù)據(jù)庫

2009-05-18 13:18:54

字符Oracle字符串

2011-03-18 11:24:07

Oracle 數(shù)據(jù)庫時間問題

2011-05-26 14:43:49

ORACLE數(shù)據(jù)庫異常處理

2011-03-17 14:09:25

Oracle數(shù)據(jù)庫字符

2009-09-02 18:52:38

Oracle數(shù)據(jù)庫并行

2010-05-07 13:28:43

Oracle數(shù)據(jù)庫

2009-03-23 10:11:59

Oracle數(shù)據(jù)庫唯一約束

2010-04-07 14:22:46

2010-04-09 14:37:08

Oracle數(shù)據(jù)庫

2009-07-02 00:00:00

OOPOracle

2009-09-04 09:54:59

數(shù)據(jù)庫名

2023-09-05 08:40:57

刪除數(shù)據(jù)庫Oracle

2011-05-18 11:19:37

Oracle優(yōu)化停機時間

2011-05-17 14:46:38

Oracle數(shù)據(jù)庫故障

2010-04-23 09:23:44

Oracle 數(shù)據(jù)庫

2011-05-26 10:30:12

Oracle數(shù)據(jù)庫約束

2015-08-21 12:59:38

Oracle數(shù)據(jù)庫

2011-03-10 13:24:26

2011-05-24 14:13:20

Oracle數(shù)據(jù)庫
點贊
收藏

51CTO技術(shù)棧公眾號