Получение дублирующихся ошибок записи от В спящем режиме, действительно ли MySQL виноват?

Ссылка Кармана Python .

у меня есть оба Изучения Python & при Программировании Python и я почти всегда перехожу к Карманной Ссылке сначала.

7
задан OMG Ponies 26 April 2011 в 03:30
поделиться

1 ответ

Increment is definitely bad if you have more than one process writing to the same table - you're bound to have collisions.

Since it is MySQL we're talking about, the easiest thing to use would be identity. In your Hibernate mapping:

<generator class="identity"/>

In your MySQL script:

CREATE TABLE IF NOT EXISTS `my_table` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `data1` int(11) NOT NULL,
  `data2` int(11) NOT NULL,
  `timestamp` datetime default NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

To alter an existing table:

ALTER TABLE `my_table`
  CHANGE COLUMN `id` `id` int(11) NOT NULL AUTO_INCREMENT=$NEW_VALUE$;

where $NEW_VALUE$ should be replaced by the next available id so that sequence does not reset to 1.

10
ответ дан 7 December 2019 в 01:24
поделиться
Другие вопросы по тегам:

Похожие вопросы: