Home > Database > Mysql Tutorial > How to Resolve ORA-01861: Literal Does Not Match Format String in SQL?

How to Resolve ORA-01861: Literal Does Not Match Format String in SQL?

Mary-Kate Olsen
Release: 2025-01-03 01:42:39
Original
434 people have browsed it

How to Resolve ORA-01861: Literal Does Not Match Format String in SQL?

SQL Error Handling: Resolving ORA-01861 for Date Format Mismatch

When attempting to insert data into a table, you may encounter the error "ORA-01861: literal does not match format string." This error occurs when a date literal in the INSERT statement does not conform to the expected format.

In the specific case highlighted in the post, the error is likely caused by the date literal '1989-12-09' not matching the format expected by the column's data type. To resolve this, it is necessary to convert the string literal to a DATE value using the TO_DATE() function.

TO_DATE('1989-12-09','YYYY-MM-DD')
Copy after login

This function takes two arguments: the string literal representing the date and the format string specifying the format of the date. In this case, the format string 'YYYY-MM-DD' indicates that the date is in the format year-month-day.

By converting the string literal to a DATE value using TO_DATE(), you ensure that the date is inserted into the table in the correct format, thus resolving the ORA-01861 error.

The above is the detailed content of How to Resolve ORA-01861: Literal Does Not Match Format String in SQL?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template