primary key - Assign same column value on a row repitition in mysql -
how achieve in mysql?
id
column primary key
if same occurances of value1 , value2 occurs,assign same id value repeating row,as highlighted below
id | value1 | value2 1 | | b 2 | c | d 1 | | b 2 | c | d 3 | e | f
this not possible. primary key dictates that value (or values in case of composite key) must unique within table.
there couple of options available:
- remove primary key (and perhaps instead create index) if rows must saved way in duplicate
- do query within application logic determine whether to-be-inserted row data exists, , in such case don't perform insert
- create query same (2), perhaps insert .. not exists clause
Comments
Post a Comment