- 工信部備案號 滇ICP備05000110號-1
- 滇公安備案 滇53010302000111
- 增值電信業務經營許可證 B1.B2-20181647、滇B1.B2-20190004
- 云南互聯網協會理事單位
- 安全聯盟認證網站身份V標記
- 域名注冊服務機構許可:滇D3-20230001
- 代理域名注冊服務機構:新網數碼
mysql默認自增ID是從1開始了,但當我們如果有插入表或使用delete刪除id之后ID就會不會從1開?了.
使用mysql時,通常表中會有一個自增的id字段,但當我們想將表中的數據清空重新添加數據時,希望id重新從1開始計數,用以下兩種方法均可.
通常的設置自增字段的方法,創建表格時添加:
create table table1(id int auto_increment primary key,...)
創建表格后添加:
alter table table1 add id int auto_increment primary key 自增字段,一定要設置為primary key.
例子,代碼如下:
alter table tablename drop column id;
alter table tablename add id mediumint(8) not null primary key auto_increment first;//phpfensi.com
方法二:alter table tablename auto_increment=0
售前咨詢
售后咨詢
備案咨詢
二維碼
TOP