Maison  >  Article  >  développement back-end  >  mysql如何 写小弟我每添加一条数据 ID+1

mysql如何 写小弟我每添加一条数据 ID+1

WBOY
WBOYoriginal
2016-06-13 12:53:49929parcourir

mysql怎么 写我每添加一条数据 ID+1
mysql怎么 写我每添加一条数据 ID+1   
比方说我有2个字段  一个是ID  一个是内容   如果我添加一条内容  自动会生成 

ID  内容
1   fwefawf

会自动生成ID 1 

如果再添加一条内容 就会自动生成ID2 以此类推

ID  内容

1   fwefawf
2   fwafawddd


------解决方案--------------------
引用:
alter table pic_1 add id int default 0 not null   auto_increment ,add primary key (id);  
我运行了这个SQL语句 没有效果啊  还是不会增加字段  我要在pic_1表添加id自增字段

运行这句,把刚id字段删了,再试下
alter table pic_1 add id int(9) primary key auto_increment
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn