postgresql数据中关键字、驼峰法、别名的坑

前言

  • 最近在使用pg和mysql时,遇到一些坑,记录一下。

关键字问题

  • 例如from to 为mysql关键字,作为字段查询时,必须加引号
SELECT `from`,`to` FROM sc;(适用于mysql)
SELECT "from" ,"to" FROM sc;(适用于mysql和pg)

驼峰法命名的字段在pg问题

  • creatTime被转成了creattime,看样子pg中全是小写
Caused by: org.postgresql.util.PSQLException: ERROR: column "creattime" does not exist
  建议:Perhaps you meant to reference the column "t_bo_topo_count.creatTime".

pg中某字段使用了函数必须指定别名

  • 在mybatis中返回值为map的时候,取值会出问题。

这里写图片描述

发布了106 篇原创文章 · 获赞 21 · 访问量 19万+

猜你喜欢

转载自blog.csdn.net/u012811805/article/details/81489006