mysql id 從1開始,mysqlid1開始

來源:互聯網
上載者:User

mysql id 從1開始,mysqlid1開始
truncate table rectContent(資料表)
清空MySQL表,怎使ID重新從1自增??

truncate語句,是清空表中的內容,包括自增主鍵的資訊。truncate表後,表的主鍵就會重新從1開始。
文法:

TRUNCATE TABLE table1
 
如果更改MYSQL的ID遞增的開始值

CREATE TABLE IF NOT EXISTS `tables` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(10) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=gb2312 AUTO_INCREMENT=1 ;

看最後的 AUTO_INCREMENT=1

預設從1開始,你改成幾就從幾開始
 

相關文章

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.