下面是我的表结构,主键id
是 的组合reportedUserId_reporteeUserId
。我用它来执行INSERT IGNORE
查询,我想在scanType
列上实现表分区,但为此,我必须将其添加到主键中,并且插入的值会因为多个值而重复scanType
,但我希望它是唯一的。
那么是否有可能在上维护唯一的记录id(reportedUserId_reporteeUserId)
并在上维护表分区scanType
?
+----------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+-------+
| id | varchar(255) | NO | PRI | NULL | |
| reportedUserId | bigint | YES | MUL | NULL | |
| reporteeUserId | bigint | YES | MUL | NULL | |
| createdTime | datetime | YES | | NULL | |
| remarks | varchar(255) | YES | | NULL | |
| contestId | bigint | YES | | NULL | |
| scanType | int | NO | | 1 | |
+----------------+--------------+------+-----+---------+-------+