在oracle中更新日期值 [英] update date value in oracle
问题描述
我需要在ORACLE SQL Developer中转换日期格式
I need to convert date format in ORACLE SQL Developer
当前格式为yyyy/mm/dd-hh:mm:ss:sss,我需要将其转换为yyyy-mm-dd hh:mm:ss CST 我不是很了解SQL,但是做了一些研究. 这是我在论坛上咨询过其他人的命令.但这会引发我无法识别的命令错误.表名是B,列名是First
The current format is yyyy/mm/dd-hh:mm:ss:sss and I need to convert it to yyyy-mm-dd hh:mm:ss CST I don't really know SQL but did some research. Here is the command that I consultanted other people on the forum. but it throws me unrecognized command error. table name is B and column name is First
UPDATAE B
set First = concat(to_char(substring(FIRST,1,4) + '-' + substring(FIRST, 6, 2) + '-' + substring(FIRST, 9, 2) + ' ' + substring(FIRST, 12, 8));
这里有人可以帮助我吗?预先感谢.
Could anyone here help me with it? thanks in advance.
推荐答案
无法识别的命令"只是UPDATE
的拼写错误:
The "unrecognized command" is merely a misspelling of UPDATE
:
UPDATAE B
// Should be
UPDATE B
要在执行UPDATE
语句之前验证结果是否符合预期,请使用SELECT
:
To verify the result is what you expect before executing the UPDATE
statement, use a SELECT
:
SELECT
to_char(substr(FIRST,1,4) || '-' || substr(FIRST, 6, 2) || '-' || substr(FIRST, 9, 2) || ' ' || substr(FIRST, 12, 8)) AS Test
FROM B
这篇关于在oracle中更新日期值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!