my_sql自动增长问题
在mysql里,如何去实现 从某个数开始自动增长1呢?比如要一个字段id,最开始是16245001,每插入一条数据它就加1
------解决方案--------------------
3.6.9. Using AUTO_INCREMENT
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)
);
INSERT INTO animals (name) VALUES
('dog'),('cat'),('penguin'),
('lax'),('whale'),('ostrich');
SELECT * FROM animals;
Which returns:
+----+---------+
| id | name |
+----+---------+
| 1 | dog |
| 2 | cat |
| 3 | penguin |
| 4 | lax |
| 5 | whale |
| 6 | ostrich |
+----+---------+
------解决方案--------------------SQL code
alter table table_name auto_increment=16245001;
------解决方案--------------------
alter table table_name auto_increment=16245001;
------解决方案--------------------
auto_increment
------解决方案--------------------
设置主键,auto_increment
------解决方案--------------------
auto_increment自动增长。