MySQL-এ প্রাইমারি কির AUTO_INCREMENT মান ১-এ রিসেট করতে ALTER TABLE ব্যবহার করুন।
সিনট্যাক্স:
alter table yourTableName auto_increment = 1;
উদাহরণ:
mysql> create table ResetPrimaryKey -> ( -> Id int auto_increment, -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.59 sec)
৪টি রেকর্ড ইনসার্ট করুন (Id: ১,২,৩,৪):
mysql> insert into ResetPrimaryKey values(); ... (৪বার)
রেকর্ড দেখান:
mysql> select *from ResetPrimaryKey;
আউটপুট:
+----+ | Id | +----+ | 1 | | 2 | | 3 | | 4 | +----+ 4 rows in set (0.00 sec)
AUTO_INCREMENT ১-এ রিসেট করুন:
mysql> alter table ResetPrimaryKey auto_increment = 1; Query OK, 0 rows affected (0.21 sec) Records: 0 Duplicates: 0 Warnings: 0
DESC দিয়ে যাচাই করুন:
mysql> desc ResetPrimaryKey;
আউটপুট (auto_increment দেখাচ্ছে):
+-------+---------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+---------+------+-----+---------+----------------+ | Id | int(11) | NO | PRI | NULL | auto_increment | +-------+---------+------+-----+---------+----------------+ 1 row in set (0.11 sec)