mysql - alter table statment to insert duplicate into another table -


i have table in there column name sp varchar(10) not null. want column unique created unique index on column . table schema follows :

create table if not exists `tblspmaster` (   `csn` bigint(20) not null auto_increment,   `sp` varchar(10) not null,   `fileimporteddate` date not null,   `amzfilename` varchar(50) not null,   `casperbatch` varchar(50) not null,   `batchprocesseddate` date not null,   `expirydate` date not null,   `region` varchar(50) not null,   `fccity` varchar(50) not null,   `vendorid` int(11) not null,   `locationid` int(11) not null,   primary key (`csn`),   unique key `sp` (`sp`) ) engine=innodb  default charset=latin1 auto_increment=10000000000 ; 

now want if tries insert duplicate record record should inserted secondary table name tblduplicate.

i have gone through question mysql - ignore insert error: duplicate entry not sure instead of

insert tbl values (1,200) on duplicate key update value=200; 

can insert duplicate row table ?

what changes needed done in main table scheme or index column ?

**note : data inserted importing excel or csv files , excel files contains 500k 800 k records there 1 single column **

i believe want use trigger this. here mysql reference chapter on triggers.

use before insert trigger. in trigger, check if row duplicate (maybe count(*) key column value = value inserted). if row duplicate, perform insert secondary table.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -