freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

oracle存儲(chǔ)過程-1-資料下載頁

2025-04-09 11:16本頁面
  

【正文】 世紀(jì)中的年份 月份 月份中的哪一天 小時(shí) 分 秒 SQL create table test_date(col_date date)。 Table created SQL insert into test_date values(to_date(39。20080627 10:35:0039。,39。yyyymmdd hh24:mi:ss39。))。 1 row inserted SQL select to_char(col_date,39。yyyymmdd hh24:mi:ss39。),dump(col_date) from test_date。 TO_CHAR(COL_DATE,39。YYYYMMDDHH DUMP(COL_DATE) 20080627 10:35:00 Typ=12 Len=7: 120,108,6,27,11,36,1 Date類型的內(nèi)部編碼為12 長(zhǎng)度:占用7個(gè)字節(jié) 數(shù)據(jù)存儲(chǔ)的每一位到第七位分別為:世紀(jì),年,月,日,時(shí),分,秒。 世紀(jì):采用”加100”表示法來存儲(chǔ)。即世紀(jì)+100來存儲(chǔ)。120 – 100 = 20 年:跟世紀(jì)一樣采用”加100”表示法來存儲(chǔ)。108 – 100 = 08(采用兩位表示) 月: 日:自然存儲(chǔ),不做修改,27 時(shí):(時(shí),分,秒都采用“加1”法存儲(chǔ))11 1= 10 分:36 1 = 35 秒:1 1 = 0 為什么世紀(jì)和年份要用加100法存儲(chǔ)呢?是為了支持BC和AD日期。 BC即為公元前。 AD即為公元。 如果世紀(jì) – 100為一個(gè)負(fù)數(shù),那么就是一個(gè)BC日期。 插入一個(gè)公元前日期 SQL insert into test_date values(to_date(39。4712010139。,39。syyyymmdd hh24:mi:ss39。))。 1 row inserted SQL select to_char(col_date,39。bc yyyymmdd hh24:mi:ss39。),dump(col_date) from test_date。 TO_CHAR(COL_DATE,39。BCYYYYMMDD DUMP(COL_DATE) 公元 20080627 10:35:00 Typ=12 Len=7: 120,108,6,27,11,36,1 公元前 47120101 00:00:00 Typ=12 Len=7: 53,88,1,1,1,1,1 我們已經(jīng)了解了日期的存儲(chǔ)結(jié)構(gòu)。當(dāng)要對(duì)日期進(jìn)行截取時(shí),比如去掉時(shí),分,秒。只需要把最后的三個(gè)字節(jié)設(shè)為:12 12 1就可以了。 SQL create table test_date1 (col_char varchar2(12), col_date date)。 Table created SQL insert into test_date1 values(39。full39。,to_date(39。20080627 12:01:0039。,39。yyyymmdd hh24:mi:ss39。))。 1 row inserted SQL insert into test_date1(col_char,col_date) select 39。minute39。, trunc(col_date,39。mi39。) from test_date1 2 union all 3 select 39。day39。, trunc(col_date,39。dd39。) from test_date1 4 union all 5 select 39。month39。,trunc(col_date,39。mm39。) from test_date1 6 union all 7 select 39。year39。,trunc(col_date,39。y39。) from test_date1 8 。 4 rows inserted SQL select col_char, col_date,dump(col_date) from test_date1。 COL_CHAR COL_DATE DUMP(COL_DATE) full 2008627 1 Typ=12 Len=7: 120,108,6,27,13,2,1 minute 2008627 1 Typ=12 Len=7: 120,108,6,27,13,2,1 day 2008627 Typ=12 Len=7: 120,108,6,27,1,1,1 month 200861 Typ=12 Len=7: 120,108,6,1,1,1,1 year 200811 Typ=12 Len=7: 120,108,1,1,1,1,1 要把一個(gè)日期截取,只取到年。數(shù)據(jù)庫只是把最后5個(gè)字節(jié)置上1。這是非??斓摹?當(dāng)我們對(duì)一個(gè)Date字段進(jìn)行操作,需要截取到年份進(jìn)行比較時(shí),我們經(jīng)常使用to_char函數(shù)。通過會(huì)這樣寫。 Select * from test_date1 where to_char(col_date ,’yyyy’) = ‘2008’ 而不是 Select * from test_date1 where trunc(col_date,’y’) = to_date(‘20080101’,’yyyymmdd’) 使用trunc會(huì)占用更少的資源,性能更優(yōu)。 使用to_char所有的CPU時(shí)間與trunc相差一個(gè)數(shù)量級(jí),差不多10倍。因?yàn)閠o_char必須把日期轉(zhuǎn)換成一個(gè)串,并利用當(dāng)前系統(tǒng)所采用的NLS來完成,然后執(zhí)行一個(gè)串與串的比較。而TRUNC只需要把后5個(gè)字節(jié)設(shè)置為1,然后將兩個(gè)7位的字節(jié)的二進(jìn)行數(shù)進(jìn)行比較就搞定了。所要截取一個(gè)DATE列葉,應(yīng)該避免使用to_char. 另外,要完全避免對(duì)DATE列應(yīng)用函數(shù)。比如我們要查詢2008年的所有數(shù)據(jù),并且這一列上也有索引,我們希望能夠用上這個(gè)索引。 SQL select count(col_date) from test_date1 where col_date = to_date(39。2008010139。,39。yyyymmdd39。) and col_date to_date(39。2009010139。,39。yyyymmdd39。)。 COUNT(COL_DATE) 5 167。 向Date類型增加或減時(shí)間 怎么向Date類型增加時(shí)間,例如:向Date增加1天,或1小時(shí),或1秒,一月等。 常有的辦法有幾個(gè)方法: 。因?yàn)镈ate 加減操作是以天為單位。1秒就是 1/24/60/60。依此類推。 。后續(xù)會(huì)介紹 。增加月不像增加天那么簡(jiǎn)單,所以需要使用內(nèi)置函數(shù)來處理。 增加秒 SQL create table test_date2(id varchar2(10), operate_time date)。 Table created SQL insert into test_date2 values(39。139。,sysdate)。 1 row inserted SQL select id, to_char(operate_time, 39。yyyymmdd hh24:mi:ss39。) from test_date2 where id=1。 ID TO_CHAR(OPERATE_TIME,39。YYYYMM 1 20080627 13:35:35 SQL update test_date2 set operate_time = operate_time + 1/24/60/60 where id=1。 1 row updated SQL select id, to_char(operate_time, 39。yyyymmdd hh24:mi:ss39。) from test_date2 where id=1。 ID TO_CHAR(OPERATE_TIME,39。YYYYMM 1 20080627 13:35:36 增加分 SQL update test_date2 set operate_time = operate_time + 1/24/60 where id=1。 1 row updated SQL select id, to_char(operate_time, 39。yyyymmdd hh24:mi:ss39。) from test_date2 where id=1。 ID TO_CHAR(OPERATE_TIME,39。YYYYMM 1 20080627 13:36:36 增加小時(shí) SQL update test_date2 set operate_time = operate_time + 1/24 where id=1。 1 row updated SQL select id, to_char(operate_time, 39。yyyymmdd hh24:mi:ss39。) from test_date2 where id=1。 ID TO_CHAR(OPERATE_TIME,39。YYYYMM 1 20080627 14:36:36 增加天 SQL update test_date2 set operate_time = operate_time + 1 where id=1。 1 row updated SQL select id, to_char(operate_time, 39。yyyymmdd hh24:mi:ss39。) from test_date2 where id=1。 ID TO_CHAR(OPERATE_TIME,39。YYYYMM 1 20080628 14:36:36 增加周 SQL update test_date2 set operate_time = operate_time + 1 * 7 where id=1。 1 row updated SQL select id, to_char(operate_time, 39。yyyymmdd hh24:mi:ss39。) from test_date2 where id=1。 ID TO_CHAR(OPERATE_TIME,39。YYYYMM 1 20080705 14:36:36 增加月 SQL update test_date2 set operate_time = add_months(operate_time,1) where id=1。 1 row updated SQL select id, to_char(operate_time, 39。yyyymmdd hh24:mi:ss39。) from test_date2 where id=1。 ID TO_CHAR(OPERATE_TIME,39。YYYYMM 1 20080805 14:36:36 增加年 SQL update test_date2 set operate_time = add_months(operate_time,1 * 12) where id=1。 1 row updated SQL select id, to_char(operate_time, 39。yyyymmdd hh24:mi:ss39。) from test_date2 where id=1。 ID TO_CHAR(OPERATE_TIME,39。YYYYMM 1 20090805 14:36:36 另外可以使用一個(gè)非常有用的函數(shù)NUMTODSINTERVAL來新增加小
點(diǎn)擊復(fù)制文檔內(nèi)容
公司管理相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1