php - Load data infile default value not inserting in table -
i'm importing csv file using load datainfile
the csv columns name,type,status
my table structure
name : varchar type : varchar status: tiny int default value 1
i use stmt :
load data infile '/var/www/names.csv' table users fields terminated ',' enclosed '"' lines terminated '\n' ignore 1 lines when use above statement has insert status value 1 each row, not inserting same. please advise.
when loading file, mysql expects has same number of columns destination table, unless specify otherwise, if missing column has default value. supply column list load statement, , literal 1 value of status:
load data infile '/var/www/names.csv' table users fields terminated ',' enclosed '"' lines terminated '\n' ignore 1 lines (`name`, `type`, 1) you can set clause:
load data infile '/var/www/names.csv' table users fields terminated ',' enclosed '"' lines terminated '\n' ignore 1 lines (`name`, `type`) set `status` = 1
Comments
Post a Comment