![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
postgresql
pei1994
小白需要坚持写博客,加油!!!
博文中参考的资料内容如没有列出或侵权,请及时留言告知。
展开
-
Mybatis mapper技巧
import org.apache.ibatis.annotations.Param;dao 层直接 按照以下 注入参数在mapper使用service 层dao 层mapper 层直接使用pg 返回主键 mapper 层判断 mapper 层返回 大于 0 , 然后直接在configPlan 类 里面 get 获取...原创 2021-06-07 09:26:07 · 76 阅读 · 0 评论 -
postgresql user表,user是其关键字
postgresql 自带user表,user是其关键字select * from user;其查询到的是系统的user;当我们想自己创建user表的时候,需要加"";create table "user"(id int,name varchar);当我们想访问自己创建的user表的时候,需要加public前缀select * from public.user;或者select * from "user";MySQL 可以直接创建user表,网上的很多Mysql创建的user表的原创 2020-11-26 09:52:23 · 1748 阅读 · 0 评论 -
Mybatis中的 ${} 和 #{}区别与用法
Mybatis 的Mapper.xml语句中parameterType向SQL语句传参有两种方式:#{}和${}我们经常使用的是#{},一般解说是因为这种方式可以防止SQL注入,简单的说#{}这种方式SQL语句是经过预编译的,它是把#{}中间的参数转义成字符串,举个例子:select * from student where student_name = #{name} 预编译后,会动态解析成一个参数标记符?:select * from student where student_name = ?转载 2020-11-19 16:58:44 · 266 阅读 · 0 评论 -
mybatis 中mapper的<foreach>标签使用
mybatis XML映射器 官方文档标签是一个循环语句,进行遍历,可以支持List、Set接口。需要配置的属性:collection:代表传递进来的参数名称,可以是一个数组、List、Set等集合item:配置的是循环中的当前元素index:配置的是当前元素在集合中的位置下标open和close:配置的是以什么符号将这些集合元素包装起来separator:是各个元素的间隔符易错点separator 参数代表每个语句后面添加相应的标志,上面的例子最终执行的SQL语句为:inse原创 2020-11-19 16:48:53 · 650 阅读 · 0 评论 -
postgresql 批量增删改
insertupdateupdate tb set name = tmp.name(此处为需要更新的字段) from (values(1,'xa',100),(2,'xb',200)) as tmp(id,name,age) where tb.id = tmp.id;注意:set 字段只更新了name,所以age并没有更新。deletedelete from tb using (values(3),(4),(5)) as tmp(id) where tb.id = tmp.id;.原创 2020-11-19 15:51:55 · 1086 阅读 · 0 评论