mysql重置自增長屬性

2021-06-26 04:37:40 字數 599 閱讀 1642

mysql在建表示,被標記為auto_increment的屬性,如:

create table test(

id int auto_increment,

name varchar(10),

primary key (host_id),

)

這樣的屬性在插入的時候只要傳入null,就會獲得自動分配,且依次增長的變數

insert into test values(null."nihao");

這樣的自增長屬性的值會一直**,可以通過

select * from information_schema.tables where table_name='test';

來檢視其中的auto_increment屬性的值來獲取現在的值

而重置的方法則是將這個值置為1

alter table test auto_increment=1;

這樣就可以了

(注意,一定要清空了這張表之後執行才有用)

mysql 去除列的自增長 mysql自增長列

自增長列必須是索引列,否則無法建立成功表,對myisma和innodb都一樣 localhost testdb root create table test5 id int auto increment,name varchar 10 engine innodb error 1075 42000 l...

重置sqlserver自增長列的種子

如果表中的資料不要了,用下面的語句 truncate table表 如果表中的語句還要,用下面的語句 dbcc checkident 表名,reseed,1 dbcc checkident table name noreseed 不重置當前標識值。dbcc checkident 返回乙個報表,它指明...

mysql復合主鍵如何設定自增長屬性

這個可以有,需注意把自增長列放在復合主鍵的第乙個位置,也就是最左邊。比如 create table t a int auto increment,b int,key a,b 這個問題分兩種情況討論。1 myisam引擎.復合索引可以包含乙個auto increment,而且這個auto increm...