Oracle 数据库 10g 快捷版和日期格式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1533381/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 19:09:45  来源:igfitidea点击:

Oracle Database 10g Express Edition AND Date Formats

sqloracleplsqloracle10gora-01843

提问by Richard Knop

I'm new to Oracle (I've been using MySQL mainly until now) so this might be a dumb question. But I have created this table (names are not english but ignore that, that is not important):

我是 Oracle 的新手(直到现在我一直主要使用 MySQL)所以这可能是一个愚蠢的问题。但是我已经创建了这个表(名称不是英文但忽略它,这并不重要):

CREATE TABLE Auta (
id_auto NUMBER(5) UNIQUE NOT NULL,
typ CHAR(10),
specifikacia_typu CHAR(15),
SPZ CHAR(8),
farba CHAR(20),
datum_vyroby DATE,
pocet_miest NUMBER(2),
pociatok_km NUMBER(6),
poplatok_denny NUMBER(4),
poplatok_km NUMBER(2));

Then I tried using this INSERT query:

然后我尝试使用这个 INSERT 查询:

INSERT INTO Auta VALUES (
1
,'Audi'
,'A6'
,'KE1-1548'
,'cierna'
,'20-12-2004'
,5
,158749
,1356
,88
);

And I get an error:

我收到一个错误:

ORA-01843: not a valid month

The date format I am using is DD-MM-YYYY. I also tried DD.MM.YYYY, DD/MM/YYYY, I also tried switching month and day like this - MM-DD-YYYY, MM/DD/YYYY - and still the same error.

我使用的日期格式是 DD-MM-YYYY。我也尝试过 DD.MM.YYYY、DD/MM/YYYY,我也尝试过像这样切换月份和日期 - MM-DD-YYYY、MM/DD/YYYY - 仍然是同样的错误。

What to do?

该怎么办?

回答by OMG Ponies

Replace:

代替:

,'20-12-2004'

...with:

...和:

, TO_DATE('20-12-2004', 'DD-MM-YYYY')

Reference: TO_DATE

参考:TO_DATE

回答by Lakshmi Dutt

oracle date format is DD-MON-YY .

oracle 日期格式为 DD-MON-YY 。

回答by raghav

Use date format of 20-april-2004instead of 20-4-2004.

使用日期格式20-april-2004而不是20-4-2004.

回答by d-coder

Use DD-MMM-YYYYformat while inserting date into the database.

在将日期插入数据库时使用DD-MMM-YYYY格式。

For example, 15-Mar-2013.

例如,15-Mar-2013