Вопрос

I have a table designed to hold daily stock-related data, and the price date is a foreign key into my calendar table. The calendar table lists all valid dates which does not include weekends. I have just gotten 20 years of daily currency exchange data, and it appears to include at least some weekends. I've created scripts with insert commands for everything, knowing I'll get an error 1452 on the weekend records (signifying the foreign key constraint fails). I'm perfectly ok with this, as mysql will try to insert the record, fail, and move on. The problem is that the error message echoes to the console for all of the thousands of insert errors. All this extra stdout printing is substantially slowing my first insert script (only 1 year, took at least 10 minutes).

How can I suppress this error message? Please don't tell that the error message is "telling me something important" or I should "pay attention to it" or I should "debug my script". I know exactly why the error is coming up, and simply want to suppress it.

Это было полезно?

Решение

You could try using INSERT IGNORE

For example:

INSERT IGNORE INTO myTable (myColumn) values ('myValue');

Should suppress your error message...

Другие советы

Open MySQL console and run :

SET GLOBAL FOREIGN_KEY_CHECKS=0;

After you finish, undo it :

SET GLOBAL FOREIGN_KEY_CHECKS=1;
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top