[英]How can i register hours on Oracle's SQL Developer 20.2 for 11g database?
I'm trying to register a DATE and and hour field on a table.我正在尝试在表上注册日期和小时字段。 DATE is there, but i can't find the TIME type for the hour field.
DATE 在那里,但我找不到小时字段的 TIME 类型。 Is there another way to make the thing?
有没有另一种方法来制作东西? Or am i missing something?
或者我错过了什么? I'm trying to register the hour on a '11:30' format.
我正在尝试以“11:30”格式注册小时。
An Oracle date
column always contains a day and a time. Oracle
date
列始终包含日期和时间。 There would generally be no reason to have a separate column to store the time.通常没有理由有一个单独的列来存储时间。
create table foo (
my_date_col date
);
insert into foo( my_date_col )
values( to_date( '2020-11-23 11:30', 'yyyy-mm-dd hh24:mi' ) );
select trunc( my_date_col ) date_data_type_at_midnight,
to_char( my_date_col, 'yyyy-mm-dd' ) string_representation_of_day,
to_char( my_date_col, 'hh24:mi:ss' ) string_representation_of_time
from foo;
There is no time
datatype in Oracle. Oracle 中没有
time
数据类型。 There is a date
datatype, that stores the date and time .有一种
date
数据类型,用于存储日期和时间。
You did not explain your actual use case, but: most of the times, you don't need, and don't want, to store the date and times in two separate columns.您没有解释您的实际用例,但是:大多数时候,您不需要也不希望将日期和时间存储在两个单独的列中。 You can use
date
, that stores both.您可以使用
date
,它存储两者。 Then you can use date functions to access the date and time parts separately if you really need to (or use computed columns).然后,如果您确实需要(或使用计算列),您可以使用日期函数分别访问日期和时间部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.