2015-06-26 90 views
0

我有如下表:的MySQL:重复条目键 '主要'

+------+--------+---------+------------+----------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+ 
| Name | Engine | Version | Row_format | Rows  | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time   | Update_time   | Check_time | Collation  | Checksum | Create_options | Comment | 
+------+--------+---------+------------+----------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+ 
| logs | MyISAM |  10 | Dynamic | 34823016 |   237 | 8285517176 | 281474976710655 | 357365760 |  192 |  34823017 | 2015-06-17 21:37:54 | 2015-06-26 15:49:21 | NULL  | utf8_general_ci |  NULL |    |   | 
+------+--------+---------+------------+----------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+ 

mysql> show columns from logs; 
+--------------------+------------------+------+-----+---------+----------------+ 
| Field    | Type    | Null | Key | Default | Extra   | 
+--------------------+------------------+------+-----+---------+----------------+ 
| ID     | int(10) unsigned | NO | PRI | NULL | auto_increment | 
| ReceivedAt   | datetime   | YES |  | NULL |    | 
| DeviceReportedTime | datetime   | YES |  | NULL |    | 
| Facility   | smallint(6)  | YES |  | NULL |    | 
| Priority   | smallint(6)  | YES |  | NULL |    | 
| FromHost   | varchar(60)  | YES |  | NULL |    | 
| Message   | text    | YES |  | NULL |    | 
| InfoUnitID   | int(11)   | YES |  | NULL |    | 
| SysLogTag   | varchar(60)  | YES |  | NULL |    | 
| CustomerID   | bigint(20)  | YES |  | NULL |    | 
| NTSeverity   | int(11)   | YES |  | NULL |    | 
| Importance   | int(11)   | YES |  | NULL |    | 
| EventSource  | varchar(60)  | YES |  | NULL |    | 
| EventUser   | varchar(60)  | YES |  | NULL |    | 
| EventCategory  | int(11)   | YES |  | NULL |    | 
| EventID   | int(11)   | YES |  | NULL |    | 
| EventBinaryData | text    | YES |  | NULL |    | 
| MaxAvailable  | int(11)   | YES |  | NULL |    | 
| CurrUsage   | int(11)   | YES |  | NULL |    | 
| MinUsage   | int(11)   | YES |  | NULL |    | 
| MaxUsage   | int(11)   | YES |  | NULL |    | 
| EventLogType  | varchar(60)  | YES |  | NULL |    | 
| GenericFileName | varchar(60)  | YES |  | NULL |    | 
| SystemID   | int(11)   | YES |  | NULL |    | 
| processid   | varchar(60)  | NO |  |   |    | 
| checksum   | int(11) unsigned | NO |  | 0  |    | 
+--------------------+------------------+------+-----+---------+----------------+ 

我想插入一行:

INSERT INTO logs (ID, ReceivedAt, DeviceReportedTime, Facility, 
Priority, FromHost, Message, InfoUnitID, SysLogTag, CustomerID, 
NTSeverity, Importance, EventSource, EventUser, EventCategory, 
EventID, EventBinaryData, MaxAvailable, CurrUsage, MinUsage, 
MaxUsage, EventLogType, GenericFileName, SystemID) 
VALUES ('34823017', 
     '2015-06-26T15:06:02+03:00', 
     '2015-06-26T15:06:38+03:00', 
     '22', 
     '6', 
     'po-sv-bus-01v', 
     'type=SYSCALL msg=audit(1435320388.132:831638): arch=c000003e syscall=4 success=yes exit=0 a0=7f4bc8616ca0 a1=7f4bd1c10c00 a2=7f4bd1c10c00 a3=0 items=1 ppid=1 pid=3489 auid=286786658 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 ses=204 tty=(none) comm="rsyslogd" exe="/sbin/rsyslogd" subj=unconfined_u:system_r:syslogd_t:s0 key="power-abuse"', 
     '1', 
     'audit: ', 
     '', 
     '', 
     '', 
     '', 
     '', 
     '', 
     '', 
     '', 
     '', 
     '', 
     '', 
     '', 
     '', 
     '', 
     ''); 

而且我歌厅错误:

ERROR 1062 (23000): Duplicate entry '34823017' for key 'PRIMARY'

虽然没有重复的条目:

mysql> select * from logs where ID = '34823017'; 

Empty set (0.00 sec) 

有人能帮助我吗?

+1

你是否没有单一的配额运行,作为选择*从日志其中ID = 34823017; – caslaner

+0

在这种情况下,只需重新启动mysql服务并再次检查它 –

+2

您有一个auto_increment ID,为什么您手动设置ID – PaulF

回答

0

请勿手动设置ID。你可以通过空作为例子,然后它会自动增加

相关问题