mysql下插入带有auto_increment字段的表
Tofloor
poster avatar
solothink
deepin
2020-11-12 23:38
Author

有不少年头不写数据库了,知识已经很陈旧了。最近在deepin下搭建了php+apache+mysql,发现插入表都举步为艰。比如表结构如下


insert into task(id,date_added,date_modified,taskname) values('','2020-11-12','2020-11-12','还贷');死活插不进去啊。后来查了好多资料,才知道,对于自动增长的字段,现在是用0。

也就是,insert into task(id,date_added,date_modified,taskname) values(0,'2020-11-12','2020-11-12','还贷');就对了,id号就会自动排序下去。如下图:




Reply Favorite View the author
All Replies
element
deepin
2020-11-13 01:19
#1

LAMP干嘛要选deepin呀。。。研究还行。。如果是要做事情还是算了

Reply View the author
solothink
deepin
2020-11-13 01:26
#2
element

LAMP干嘛要选deepin呀。。。研究还行。。如果是要做事情还是算了

我就是自己写个小应用自己用用的。

Reply View the author
element
deepin
2020-11-13 17:05
#3

你这个是数据库表没有设置id自增长导致的。。

Reply View the author
solothink
deepin
2020-11-13 18:32
#4
It has been deleted!
solothink
deepin
2020-11-13 18:35
#5
element

你这个是数据库表没有设置id自增长导致的。。

应该有的,默认自动增长是5,我还特意修改为1了。我想是现在mysql的语法不一样了,以前自动增长对应的用'',也有用null的,这个用0

Reply View the author