最为基础的列,使用说明:

对象

描述

new Column("name")

name

new Column("a", "name")

a.name

new Column("a", "name", "username")

a.name AS username

new Column(Expression.SUM,

"a", "name", "username")

sum(a.name) AS username

new Column().function(Expression.SUM)

.alias("a")

.name("name")

.as("username");

sum(a.name) AS username

new Column().function(Expression.SUM)

.alias("a")

.name("name")

.operator(OperatorType.MULTIPLY)

.value(1000);

sum(a.name) * 1000

new Column().function(Expression.SUM)

.alias("a")

.name("name")

.operator(OperatorType.MULTIPLY)

.operatorInFunction(true)

.value(1000);

sum(a.name * 1000)

 

format 属性说明,按String.format格式书写:

 

数据库

格式

说明

MySQL

Column column = new Column("a", "name");

column.format("date_format(%s,'%%Y-%%m-%%d')");

date_format(a.name,'%Y-%m-%d')"

Oracle

Column column = new Column("a", "name");

column.format("to_char(%s,

 'YYYY-MM-DD hh24:mi:ss')");

to_char(a.name,'YYYY-MM-DD  hh24:mi:ss')

SQLServer

Column column = new Column("a", "name");

column.format("CONVERT(varchar, %s, 101)");

CONVERT(varchar, a.name, 101)

PostgreSQL

Column column = new Column("a", "name");

column.format("to_char(%s,

 'YYYY-MM-DD hh24:mi:ss')");

to_char(a.name,'YYYY-MM-DD hh24:mi:ss')

 

目录
Copyright © objectsql.com 2021 闽ICP备17009107号-3

闽公网安备 35020302035600号