int insert(T record);
int insertSelective(T record);
insertSelective 对应的 SQL 语句加入了 NULL 检验,只会插入数据不为 null 的字段,而 insert会插入所有字段,会插入 null 数据。
也就意味着如果定义了表 default 字段,使用 insert 还是会插入 null 而忽略 default
insertSelective 当字段为 null 时会用 default 自动填充
博客介绍了SQL语句插入数据时的情况。普通插入语句会插入所有字段,包括null数据,即便表定义了default字段也会插入null;而insertSelective在字段为null时会用default自动填充,还给出了参考链接。
int insert(T record);
int insertSelective(T record);
insertSelective 对应的 SQL 语句加入了 NULL 检验,只会插入数据不为 null 的字段,而 insert会插入所有字段,会插入 null 数据。
也就意味着如果定义了表 default 字段,使用 insert 还是会插入 null 而忽略 default
insertSelective 当字段为 null 时会用 default 自动填充
转载于:https://www.cnblogs.com/hinux/p/11165977.html
3478
7794
7064
598

被折叠的 条评论
为什么被折叠?
