自动递增它不起作用

时间:2015-03-11 02:04:13

标签: mysql

我的网站上有自动增加的问题,我找不到解决方法...

它适用于此表:

CREATE TABLE IF NOT EXISTS `users` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `username` varchar(40) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
    `password` varchar(40) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
    `loginhash` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL,
    `id_level` int(10) NOT NULL DEFAULT '1',
    `random` int(10) DEFAULT '0',
    `email` varchar(30) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
    `language` tinyint(4) NOT NULL DEFAULT '1',
    `style` tinyint(4) NOT NULL DEFAULT '1',
    `joined` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    `lastconnect` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    `lip` bigint(11) DEFAULT '0',
    `downloaded` bigint(20) DEFAULT '0',
    `uploaded` bigint(20) DEFAULT '0',
    `avatar` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
    `pid` varchar(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
    `flag` tinyint(1) unsigned NOT NULL DEFAULT '0',
    `topicsperpage` tinyint(3) unsigned NOT NULL DEFAULT '15',
    `postsperpage` tinyint(3) unsigned NOT NULL DEFAULT '15',
    `torrentsperpage` tinyint(3) unsigned NOT NULL DEFAULT '15',
    `cip` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL,
    `time_offset` varchar(4) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
    `temp_email` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
    `flags` bigint(20) unsigned NOT NULL DEFAULT '7345036',
    PRIMARY KEY (`id`),
    UNIQUE KEY `username` (`username`),
    KEY `id_level` (`id_level`),
    KEY `pid` (`pid`),
    KEY `cip` (`cip`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

但它不适用于此表:

CREATE TABLE IF NOT EXISTS `users` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `username` varchar(40) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
    `password` varchar(40) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
    `loginhash` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL,
    `id_level` int(10) NOT NULL DEFAULT '1',
    `random` int(10) DEFAULT '0',
    `email` varchar(30) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
    `language` tinyint(4) NOT NULL DEFAULT '1',
    `style` tinyint(4) NOT NULL DEFAULT '1',
    `joined` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    `lastconnect` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    `lip` bigint(11) DEFAULT '0',
    `downloaded` bigint(20) DEFAULT '0',
    `uploaded` bigint(20) DEFAULT '0',
    `avatar` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
    `pid` varchar(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
    `flag` tinyint(1) unsigned NOT NULL DEFAULT '0',
    `topicsperpage` tinyint(3) unsigned NOT NULL DEFAULT '15',
    `postsperpage` tinyint(3) unsigned NOT NULL DEFAULT '15',
    `torrentsperpage` tinyint(3) unsigned NOT NULL DEFAULT '15',
    `cip` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL,
    `time_offset` varchar(4) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
    `temp_email` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
    `flags` bigint(20) unsigned NOT NULL DEFAULT '7345036',
    `rank_switch` enum('yes','no') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'no',
    `old_rank` varchar(12) COLLATE utf8_unicode_ci NOT NULL DEFAULT '3',
    `timed_rank` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    `seedbonus` decimal(5,1) NOT NULL,
    `on_forum` int(11) NOT NULL DEFAULT '0',
    `on_topic` int(11) NOT NULL DEFAULT '0',
    `custom_title` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
    `invites` int(10) NOT NULL DEFAULT '0',
    `invited_by` int(10) NOT NULL DEFAULT '0',
    `invitedate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    `donor` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'no',
    `banfromforum` enum('yes','no') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'no',
    PRIMARY KEY (`id`),
    UNIQUE KEY `username` (`username`),
    KEY `id_level` (`id_level`),
    KEY `pid` (`pid`),
    KEY `cip` (`cip`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

谁能告诉我问题出在哪里?

0 个答案:

没有答案