GBASE可以使用postgresql的数据库连接方式
pom引用
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.5.1</version>
</dependency>
连接配置
driverClassName: org.postgresql.Driver
url: jdbc:postgresql://127.0.0.1:14005/dbName?currentSchema=schemaName
username: test
password: 123456
mybatis-plus分页拦截器配置
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
// 开启 PageHelper 的支持
paginationInterceptor.setLocalPage(true);
paginationInterceptor.setDialectType(DBType.POSTGRE.getDb());
return paginationInterceptor;
}
和MySQL的语法区别
1.使用 order by col 语句时,col 需要存在于select 里面
2.分页语法:limit 10 offset 10 ,limit表示每页条数,offset表示跳过前面多少条
3.select column a from table,a 前面要有 as
4.同一个schema中表索引名称不能重复
5.修改索引名称的语句不同
6.group by 的使用除了分组列以外,其余要展示的列必须要结合计算,比如avg,sum
7.主键自增设置
CREATE SEQUENCE table_id_seq START 1;
alter table schemaName.table alter column ID set default nextval('schemaName.table_id_seq');
8.使用navicat工具将MySQL中的double类型转为gbase时,会改成float,用Java类BigDecimal取值时小数点后会变很长,需要将float改成numeric
9.分组合并函数用string_agg(column,‘,’),等同于mysql中的GROUP_CONCAT