您的位置:首页 > 数据库 > MySQL

9、mysql中auto_increment的简单使用

2011-11-11 14:51 309 查看
1、auto_increment的复位

ALTER TABLE your_table_name AUTO_INCREMENT = 1

2、The AUTO_INCREMENT attribute can be used to generate a unique identity for new rows。示例:

CREATE TABLE animals (

     id MEDIUMINT NOT NULL AUTO_INCREMENT,

     name CHAR(30) NOT NULL,

     PRIMARY KEY (id)

) ENGINE=MyISAM;

INSERT INTO animals (name) VALUES

    ('dog'),('cat'),('penguin'),

    ('lax'),('whale'),('ostrich');

3、No value was specified for the AUTO_INCREMENT column, so MySQL assigned sequence numbers automatically. You can also explicitly assign NULL or 0 to the column to generate sequence numbers.

参考

【1】 关于auto_increment的一个应用讨论

http://www.iteye.com/topic/198779

【2】 mysql官网

http://www.w3school.com.cn/sql/sql_datatypes.asp

http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html

http://dev.mysql.com/doc/refman/5.1/zh/column-types.html#numeric-type-overview

【3】 使用auto_increment经验总结

http://www.frostsky.com/2011/04/mysql-auto_increment-2/

【4】 总结的不错

http://www.bhcode.net/article/20090219/4161.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: