mysql load data infile auto_increment mutiple incrementation -


while executing same file multiple times auto incrementation value wrong. file sample.csv

name,phone,address a,9401003026,dsa b,9658746542,fsa c,9865742310,hgfh d,9865869537,hf e,9401003026,hf s,9658746542,hf h,9865742310,hf j,9865869537,hf 

and query

load data local infile '/home/anson/ansonbackup/python/newtest/sample.csv'                table `sample`  columns terminated ','              lines terminated '\n' ignore 1 lines             (named,phone,address); 

if excecute 1 time value of id 8 when reexecute same file id starts 16..why????

my table

create table `sample` (   `id` int(11) not null auto_increment,   `named` varchar(30) default null,   `phone` varchar(30) default null,   `address` varchar(30) default null,   primary key (`id`) ) engine=innodb default charset=latin1 

if possible, never depend on auto_increment columns have values, same issue describe can happen. id gets increased every time insert in table.

if need to, include id field in csv also, import sentence be:

load data local infile '/home/anson/ansonbackup/python/newtest/sample.csv'            table `sample`  columns terminated ','          lines terminated '\n' ignore 1 lines         (id, named, phone, address); 

or, if can't that, have reset counter, this:

alter table tablename auto_increment = 1; 

with correct auto_increment need instead of 1. more info here: related answer


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -