mysql - Importing sql files to DB via Terminal. Is there a way to set default value for "ERROR 1366 at line ***: Incorrect integer value: ''? -


using terminal (ubuntu 15.10_64 + mysql 5.6) im inserting sql files database command:

for in *.sql; mysql -u login_name -ppassword countries_mysql < $i; done 

where *.sql files contain strings like:

insert region (id,vkl,tip,samonazvanie,mfa,stolica,samonazvanie_1,oficialno_1,cvet,flag,flag_svg,gerb,gerb_svg,mir_id,obj_id,kontinent,strana_id,region_id,ksi1,ksi2,ksi_sort,ksi_lat,iso_kod,gn_kod,telefon,pochta,avto,naselenie,ploshad,giddom,shirota_gradus,shirota_minuta,shirota_sekunda,dolgota_gradus,dolgota_minuta,dolgota_sekunda,sozdan,izmenen,vrem_pojas,dop_nazvanie,status,reforma_id,sxema_maska,tabl_id,tabl,pre_tabl,pre_id,post_tabl,post_id,uroven,nazvanie_1,opisanie_1,nazvanie_2,opisanie_2) values ('60448','0','0','gmina zalesie','','0','','','','','','','','0','0','0','130','52529','','','','','','','','','','0.000','0.000','http://www.giddom.com','0','0','0.00','0','0','0.00','2013-05-02 01:47:11','2015-01-25 13:21:36','','','8','0','0','0','','','0','','0','3','Залесе',''); 

and receive lot (thousands) of errors of kind:

error 1366 (hy000) @ line 61891: incorrect integer value: '' column 'post_id' @ row 1 

is there way using bash or else, without changing sql files, set default value column 'post_id' in case of error? like:

if post_id == '':     post_id = '0' 

or somehow intercept errors.

i tried find answer in internet , @ so, found php solutions (i not work php) or editing sql files (i have 200 files , of them have 1m lines).

i cant make new correct dumps, because files downloaded internet.

quickest way change definition column varchar, imports, substitute nulls in case of empty strings , change post_id column original data type.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -