I have a batch file that was created for an Oracle database that I’m now trying to import to a MySQL database. I’ve had to deal with all sorts of inconsistencies between the two. The file has all the dates as ’17-NOV-1981′ rather than ‘1981-11-17’ as MySQL expects.
The batch file had the command ALTER SESSION set nls_date_format=’DD-MON-YYYY’; to set the date format. Is there an equivalent in MySQL to get it to accept the dates as is without having to majorly edit the file?
I don’t believe it’s possible without modifying the SQL.
STR_TO_DATE could be used in the insert statements to convert the strings, or you could try piping the file through sed and use a regex to spot dates and rework them, e.g. something like this would replace single quoted dates in your original dump with calls to str_to_date, and pipe the resulting transformed sql into mysql…