萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> mysql教程 >> mysql 自定義主鍵步長方法

mysql 自定義主鍵步長方法

mysql教程 自定義主鍵步長方法
CREATE TABLE IF NOT EXISTS `useradmin` (
  `id` int(4) NOT NULL auto_increment,
  `username` varchar(20) default NULL,
  `userpass` varchar(40) default NULL,
  `logins` int(4) NOT NULL default '0' COMMENT '登陸次數',
  `logintime` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `mid` char(1) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;

SET @auto_increment_increment=10;
o                       Query OK, 0 rows affected (0.00 sec)
o                     
o                       mysql> SHOW VARIABLES LIKE 'auto_inc%';
o                       +--------------------------+-------+
o                       | Variable_name            | Value |
o                       +--------------------------+-------+
o                       | auto_increment_increment | 10    |
o                       | auto_increment_offset    | 1     |
o                       +--------------------------+-------+
o                       2 rows in set (0.01 sec)
o                     
o                       mysql> INSERT INTO useradmin VALUES ('www.111cn.net'), (NULL), (NULL), (NULL);
o                       Query OK, 4 rows affected (0.00 sec)
o                       Records: 4  Duplicates: 0  Warnings: 0
o                     
o                       mysql> SELECT col FROM autoinc1;
o                       +-----+
o                       | col |
o                       +-----+
o                       |   1 |
o                       |  11 |
o                       |  21 |
o                       |  31 |
o                       +-----+
o                       4 rows in set (0.00 sec)

copyright © 萬盛學電腦網 all rights reserved