简体   繁体   English

如何在 Oracle 的 SQL Developer 20.2 上为 11g 数据库注册小时数?

[英]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.

相关问题 如何使用少于2个注册Oracle 11g查找名称 - how can i find the name with the less than 2 register Oracle 11g 在Oracle SQL Developer上Oracle 11g连接失败 - Oracle 11g connection fails on oracle SQL developer 是否可以在Oracle Express 11g数据库与SQL Server之间创建数据库链接,还是我需要完整的11g? - Is it possible to create a database link between an Oracle Express 11g database to a SQL Server or do I need full 11g? 将SQL Developer从lubuntu到centos连接到Oracle 11g - Connecting sql developer to oracle 11g from lubuntu to centos 在Ubuntu或Windows 7上安装Oracle 11g和Sql Developer - Install Oracle 11g and Sql Developer on Ubuntu or windows 7 在sql developer中组织查询结果(oracle 11g) - organizing query result in sql developer (oracle 11g) Oracle 11g:Sql Developer:如何执行多个匿名块 - Oracle 11g : Sql Developer : How to execute more than one anonymous block 如何使用行值动态 select Oracle SQL 11g 中的列名? - How can I use a row value to dynamically select a column name in Oracle SQL 11g? oracle 数据库 11g 和 18c 有什么区别? oracle sql 开发人员和 oracle 顶点与这些有什么关系? - Whats the difference between oracle database 11g and 18c? and what do oracle sql developer and oracle apex have to do with these? 如何在使用Oracle 11g的SQL Developer中创建允许手动和自动主键的触发器 - How to create a trigger to allow both manual and auto primary key in sql developer with oracle 11g
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM