在线精品99_中国九九盗摄偷拍偷看_91免费版在线观看_91.app_91高清视频在线_99热最新网站

如何理解oracle的interval时间格式

112次阅读
没有评论

共计 2909 个字符,预计需要花费 8 分钟才能阅读完成。

本篇文章为大家展示了如何理解 oracle 的 interval 时间格式,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

INTERVAL:时间间隔

INTERVAL YEAR TO MONTH,年份和月份之间必须有 -
包含年、月的一段时间的间隔
INTERVAL integer [- integer] {YEAR | MONTH} [(precision) ] [TO { YEAR | MONTH} ]

integer [-integer] specifies integer values for the leading and optional trailing field of the literal. If the leading field is YEAR and the trailing field is MONTH, then the range of integer values for the month field is 0 to 11.
precision is the maximum number of digits in the leading field. The valid range of the leading field precision is 0 to 9 and its default value is 2.
Restriction on the Leading Field:If you specify a trailing field, then it must be less significant than the leading field. For example, INTERVAL  0-1  MONTH TO YEAR is not valid.
integer [-integer] 指定前导和可选的尾随字段的整型值。如果前导的字段是年份,而尾随字段是月, 月字段的整数值范围为 0 到 11。
precision   指定前导字段的最大位数。前导字段精度的有效范围为 0 到 9,其默认值为 2。
前导列的限制:如果您指定了一个尾随字段,那么它就必须小于前导字段。例如,INTERVAL 0-1 月到 YEAR 是无效的。

select sysdate,sysdate +  interval 1 year from dual;– 当前时间 + 1 年
select sysdate,sysdate+numtoyminterval(1, year) as res from dual;– 当前时间 + 1 年
select sysdate,sysdate +  interval 1-0 year to month from dual;– 当前时间 + 1 年
select sysdate,sysdate +  interval 1-1 year to month from dual;– 当前时间 + 1 年 1 月
select sysdate,sysdate +  interval 100 year(3) from dual;– 当前时间 +100 年
select sysdate,sysdate +  interval 100-1 year(3) to month from dual;– 当前时间 +100 年 1 月

select sysdate,sysdate +  interval 100 year(2) from dual;– 报错 ORA-01873: 间隔的前导精度太小,因为 100 是 3 位数,而 2 只指定了两位
select sysdate,sysdate +  interval 100-1 year(2) to month from dual;– 报错 ORA-01873: 间隔的前导精度太小,因为 100 是 3 位数,而 2 只指定了两位

INTERVAL DAY TO SECOND
包含天、小时、分钟、秒的一段时间的间隔
INTERVAL {integer | integer time_expr | time_expr}
{{ DAY | HOUR | MINUTE} [(leading_precision) ]
| SECOND [(leading_precision [, fractional_seconds_precision]) ]
}
[TO { DAY | HOUR | MINUTE | SECOND [ (fractional_seconds_precision) ] } ]

integer specifies the number of days. If this value contains more digits than the number specified by the leading precision, then Oracle returns an error.
time_expr specifies a time in the format HH[:MI[:SS[.n]]] or MI[:SS[.n]] or SS[.n], where n specifies the fractional part of a second. If n contains more digits than the number specified by fractional_seconds_precision, then n is rounded to the number of digits specified by the fractional_seconds_precision value. You can specify time_expr following an integer and a space only if the leading field is DAY.
integer 指定天数。如果这个值包含的数字超过了主要精度指定的数字,那么 Oracle 将返回一个错误。
time_expr 指定格式 HH:MI:SS 的时间。

select sysdate,sysdate+1 from dual;– 当前时间 + 1 天
select sysdate,sysdate +  interval 1 day from dual;– 当前时间 + 1 天
select sysdate,sysdate+numtodsinterval(1, day) as res from dual;– 当前时间 + 1 天
select sysdate,sysdate +  interval 1 0 day to hour from dual;– 当前时间 + 1 天
select sysdate,sysdate +  interval 1 1 day to hour from dual;– 当前时间 + 1 天 1 小时
select sysdate,sysdate +  interval 1 01:01 day to minute from dual;– 当前时间 + 1 天 1 小时 1 分钟
select sysdate,sysdate +  interval 1 01:01:01 day to second from dual;– 当前时间 + 1 天 1 小时 1 分钟 1 秒
select sysdate,sysdate -interval 1 year,sysdate -interval 1 month,sysdate -interval 1 day,sysdate -interval 1 HOUR,sysdate -interval 1  MINUTE,sysdate-interval 1 second from dual;
– 此刻、1 年前、1 月前、1 天前、1 小时前、1 分钟、1 秒前的时间点

上述内容就是如何理解 oracle 的 interval 时间格式,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注丸趣 TV 行业资讯频道。

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-18发表,共计2909字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)
主站蜘蛛池模板: 午夜毛片视频高清不卡免费 | 毛片免费观看 | 亚洲欧美一级久久精品 | 鲁大师成人精品视频 | 精品乱人伦一区二区三区 | 一级国产| 青青草成人网 | 老头边吃奶边弄进去呻吟 | 亚洲av电影院在线观看 | 色老头福利视频在线观看 | 日本精品久久久久久福利 | 国产精品久久久久影院色老大 | 亚洲精品自产拍在线观看动漫 | 国产欧美精品亚洲日本一区 | 亚洲国产精品欧美日韩一区二区 | 看亚洲a级一级毛片 | 免费在线观看的毛片 | 三年中文在线观看免费大全 | 中国一级特黄真人毛片免费看 | 国产精品久久久久久小说 | 欧美大片日韩精品四虎影视 | 欧美一级片在线视频 | 欧美另类 videos黑人极品 | 99久久99久久精品 | 五月天激情电影 | 国模冰莲自慰肥美胞极品人体图 | 一本一道人人妻人人妻αv 一本一道色欲综合网中文字幕 | 久久国产精品一区二区 | 人人狠狠综合久久亚洲婷婷 | 91麻豆精品国产91久久久久久 | 成人免费视频一区二区 | 国产精品国产三级国产普通话一 | 亚洲精品久久久无码av片软件 | 好男人www在线影院官网 | 精品国产不卡一区二区三区 | 欧美自拍嘿咻内射在线观看 | 日本人亚洲人jizz | 色啪网| 99精品国产高清一区二区麻豆 | 在线播放免费人成毛片乱码 | 久久亚洲福利 |