mysql自動增長更新

2021-07-24 15:53:56 字數 411 閱讀 1417

有些用的mysql自動增長時刪除一條資料後再將id重新設定,有的上set id = (id -1) 但當id在中間要刪除的時候這樣要出錯 ,我就果斷換了另乙個方法

#1,刪除原有主鍵:

alter table `am_apk` drop `id`;

#2,新增新主鍵字段:

alter table `am_apk` add `id` mediumint( 8 ) not null first;

#3,設定新主鍵:

alter table `am_apk` modify column `id` mediumint( 8 ) not null auto_increment,add primary key(id);

網上查的,留著以後用。這個可以隔很長時間執行一次都可以,他是把所有的主鍵乾掉再重新搞上,完美。

mysql 自動增長

create table teacher t id int primary key auto increment,auto increment 自動增長 需要整型,還需要索引 設定自動增長的起始值,之後插入的資料會從10開始自動增長 alter table tab name auto increme...

mysql自動增長 sql SQL的自動增長

用於 oracle 的語法 在 oracle 中,稍微複雜一點。您必須通過 sequence 對建立 auto increment 字段 該物件生成數字序列 請使用下面的 create sequence 語法 create sequence seq person minvalue 1 start w...

MySql 主鍵自動增長

mysql alter table user modify id integer auto increment query ok,1 row affected 0.28 sec records 1 duplicates 0 warnings 0 給主鍵增加乙個自增的功能 mysql create d...