設定MySQL自動成長從某個指定的數開始

來源:互聯網
上載者:User

標籤:


自增欄位,一定要設定為primary key.

以指定從1000開始為例。
1 建立表的時候就設定:

CREATE TABLE `Test` (          `ID` int(11) NOT NULL AUTO_INCREMENT,          `NAME` varchar(50) NOT NULL,             `SEX` varchar(2) NOT NULL,          PRIMARY KEY (`ID`)                    ) ENGINE=MEMORY AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC

 
2 如果在建立表時沒有設定,後來想設定,可以通過修改實現:

alter   table   Test   auto_increment   =   1000; 

 


create table user(  id integer primary key,  firstname varchar(200) not null,  lastname varchar(200) not null);  alter table user modify id integer auto_increment ;  alter table user modify id integer default ‘1‘; 

 

 

 

REF:

http://stevenjohn.iteye.com/blog/976397

http://www.cnblogs.com/macro-cheng/archive/2011/11/08/mysql-003.html

設定MySQL自動成長從某個指定的數開始

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.