[英]Update Oracle timestamp to current date
I have a TIMESTAMP(6) field in Oracle db. 我在Oracle db中有一个TIMESTAMP(6)字段。 Value of this field is in format
该字段的值以格式显示
DD/MM/YYYY HH:MM:SS.000000000 PM
How to update this value to the current timestamp? 如何将此值更新为当前时间戳?
[a link to a similar question:] update date value in oracle [类似问题的链接:] 更新oracle中的日期值
I followed this link, but following query is taking very long time to execute. 我按照这个链接,但以下查询需要很长时间才能执行。
update table_name set start_time = to_char(to_date(start_time, 'yyyy/mm/dd-hh:mi:ss:ff3'), '2012/10/10-19:30:00:00') where column='Q'
A timestamp is a point in time, it has no format. 时间戳是一个时间点,它没有格式。 To update such a field to the current timestamp, use
SYSTIMESTAMP
or CURRENT_TIMESTAMP
(respectively the date/time of the server and the date/time of the session): 要将此字段更新为当前时间戳,请使用
SYSTIMESTAMP
或CURRENT_TIMESTAMP
(分别为服务器的日期/时间和会话的日期/时间):
UPDATE your_table
SET your_column = systimestamp
WHERE ...
If the query takes an abnormal amount of time (much longer than a comparable SELECT with the same WHERE clause), the mostly likely causes are: 如果查询花费了异常的时间(比具有相同WHERE子句的类似SELECT长得多),最可能的原因是:
Why you don't just 为什么你不这样做
update table_name
set start_date = systimestamp
where column='Q'
If you suspect there are locks on the table, there are some tables to check: dba_locks
, v$session
, v$session_blockers
etc. These are useful when a user blocked something with an accidental update
without a commit
or rollback
, but you should be able to see if can exists blocking locks from the architecture of your application. 如果您怀疑表上有锁,则需要检查一些表:
dba_locks
, v$session
, v$session_blockers
等。当用户在没有commit
或rollback
情况下阻止某些意外update
时,这些表非常有用,但您应该是能够查看是否存在阻止来自应用程序体系结构的锁定。 You should just simulate on paper all the scenarios. 你应该在纸上模拟所有场景。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.