oracle 错误报告- ORA-01861:文字与格式字符串不匹配

kd3sttzy  于 2022-11-03  发布在  Oracle
关注(0)|答案(1)|浏览(295)
CREATE TABLE TableTwo
(
    OrderNumber NUMBER(10) PRIMARY KEY,
    FirstSeenDate DATE,
    Street1 VARCHAR(20),
    Street2 VARCHAR(20),
    City VARCHAR(12),
    State VARCHAR(2),
    Zip VARCHAR(5),
    LastModifiedDate DATE 
) ;

INSERT INTO TableTwo (OrderNumber, FirstSeenDate, Street1, City, State, Zip, LastModifiedDate)
VALUES ('1234567899', '2022-08-20', 'P.O BOX 340', 'Boca Raton', 'FL', '33435','2022-10-12');
qf9go6mv

qf9go6mv1#

如果您使用的是日期文字,则需要提供格式掩码或使用DATE文字,例如:

INSERT INTO TableTwo (OrderNumber, FirstSeenDate, Street1,  City, State, Zip, LastModifiedDate)
VALUES ('1234567899', to_date('2022-08-20','YYYY-MM-DD'), 'P.O BOX 340', 'Boca Raton', 'FL', '33435',to_date('2022-10-12','YYYY-MM-DD');

INSERT INTO TableTwo (OrderNumber, FirstSeenDate, Street1,  City, State, Zip, LastModifiedDate)
VALUES ('1234567899', DATE '2022-08-20', 'P.O BOX 340', 'Boca Raton', 'FL', '33435',  DATE '2022-10-12');

如果在上述两个选项中没有指定as,则oracle将假定日期字符串采用NLS_DATE_FORMAT参数- www.example.com定义的格式https://docs.oracle.com/cd/B19306_01/server.102/b14237/initparams122.htm#REFRN10119。

相关问题