[Reprint] support common database differential control instructions to support common database differential control instructions

Support for common database differential control instructions

 
HTTPS: // www.cnblogs.com/WuXuanKun/p/5317124.html 

there is actually oscar Shenzhou Universal Database ..

 

                                                                                             Support for common database differential control instructions

class

item

Oracle

SQLServer 2005(+)

MYSQL 4.x

OSCAR

DB2

service

JDBC port

1521

1433 (requires patch)

3306

2003

 

Field Type

character

VARCHAR2

VARCHAR

VARCHAR   or TEXT

VARCHAR

VARCHAR

Numerical

NUMBER

NUMERIC

DECIMAL

NUMERIC/DECIMAL

NUMERIC

Boolean

NUMBER(1)

NUMERIC(1)

DECIMAL(1)

NUMERIC(1)

NUMERIC

Date Time

DATE

DATETIME

DATETIME

TIMESTAMP

(DATE only store date values)

DATE

function

System function of time

sysdate

getdate()

now()

getdate()   or current_date

current   date

Long date conversion function

to_date(‘值’,’YYYY-mm-dd hh24:mi:ss’)

'value'

'value'

to_timestamp(‘值’,’YYYY-mm-dd hh24:mi:ss’)

'value'

Short date conversion function

to_date(‘值’,’YYYY-mm-dd’)

'value'

'value'

to_date(‘值’,’YYYY-mm-dd’)

'value'

SQL syntax

Create fields

ALTER   TABLE …  ADD …

ALTER   TABLE … ADD …

ALTER   TABLE … ADD …

ALTER   TABLE … ADD …

ALTER   TABLE … ADD  COLUMN …

Modify the field

ALTER   TABLE … MODIFY(…)

ALTER   TABLE … ALTER COLUMN …

ALTER   TABLE … CHANGE …

ALTER   TABLE … ALTER COLUMN …

ALTER   TABLE … ALTER COLUMN …

Delete field

ALTER   TABLE … DROP COLUMN

ALTER   TABLE … DROP COLUMN …

ALTER   TABLE … DROP …

ALTER   TABLE … DROP …

 

Create a table

CREATE   TABLE … ()

CREATE   TABLE … ()

CREATE   TABLE … ()

CREATE   TABLE … ()

CREATE   TABLE … ()

Create a regular index

CREATE   INDEX … ON … ()

CREATE   INDEX … ON … ()

CREATE   INDEX … ON … ()

CREATE   INDEX … ON … ()

CREATE   INDEX … ON … ()

Create a unique index

CREATE   UNIQUE INDEX … ON …()

CREATE   UNIQUE INDEX … ON …()

CREATE   UNIQUE INDEX … ON …()

CREATE   UNIQUE INDEX … ON …()

CREATE   UNIQUE INDEX … ON …()

Delete Index

DROP   INDEX indexname

DROP   INDEX table.indexname

ALTER   TABLE … DROP INDEX indexname

DROP   INDEX indexname

DROP   INDEX indexname

 

other:

DB Provider

SQL Paging Syntax

JDBC URL Sample

Oracle

select * from (select rownum r, t1. * from tableName t1 where other conditions and rownum <(number of lines per page +1 * current) order by id) t2 where t2.r> ((this page -1) * Per the number of rows page)

oracle.jdbc.driver.OracleDriver

jdbc:oracle:thin:@192.168.0.3:1521:prj

SQLServer

select * from (select rownum r, t1. * from tableName t1 where other conditions and rownum <(number of lines per page +1 * current) order by id) t2 where t2.r> ((this page -1) * Per the number of rows page)

net.sourceforge.jtds.jdbc.Driver

jdbc:jtds:sqlserver://192.168.0.2:1433/finaltest;characterEncoding=gb2312

MYSQL

select * from tableName t1 where other conditions order by id limit returns the offset rows Returns the maximum number of rows

Offset start value is 0

com.mysql.jdbc.Driver

jdbc:mysql://localhost:3306/aws40_test1?characterEncoding=gb2312

Oscar

select * from   tableName t1 where 其他条件   order by id limit count OFFSET offset

count至多返回count行

offset在开始返回第一行之前要忽略的行数

com.oscar.Driver

jdbc:oscar://localhost:2003/osrdb

DB2

SELECT   * FROM (Select rownumber() over() as row,taball.* from ( select * from tableName   where 其他条件 order by   id) as taball) AS tabpage WHERE tabpage.row BETWEEN 起始行数 AND 结束行数

com.ibm.as400.access.AS400JDBCDriver

jdbc:as400://172.16.16.7/AWS

                                                                                             支持常见数据库差异对照说明

Oracle

SQLServer 2005(+)

MYSQL 4.x

OSCAR

DB2

服务

JDBC端口

1521

1433(需要补丁)

3306

2003

 

字段类型

字符

VARCHAR2

VARCHAR

VARCHAR   or TEXT

VARCHAR

VARCHAR

数值

NUMBER

NUMERIC

DECIMAL

NUMERIC/DECIMAL

NUMERIC

布尔

NUMBER(1)

NUMERIC(1)

DECIMAL(1)

NUMERIC(1)

NUMERIC

日期时间

DATE

DATETIME

DATETIME

TIMESTAMP

(DATE只能存储日期值)

DATE

函数

系统时间函数

sysdate

getdate()

now()

getdate()   or current_date

current   date

长日期转换函数

to_date(‘值’,’YYYY-mm-dd hh24:mi:ss’)

‘值’

‘值’

to_timestamp(‘值’,’YYYY-mm-dd hh24:mi:ss’)

‘值’

短日期转换函数

to_date(‘值’,’YYYY-mm-dd’)

‘值’

‘值’

to_date(‘值’,’YYYY-mm-dd’)

‘值’

SQL语法

创建字段

ALTER   TABLE …  ADD …

ALTER   TABLE … ADD …

ALTER   TABLE … ADD …

ALTER   TABLE … ADD …

ALTER   TABLE … ADD  COLUMN …

修改字段

ALTER   TABLE … MODIFY(…)

ALTER   TABLE … ALTER COLUMN …

ALTER   TABLE … CHANGE …

ALTER   TABLE … ALTER COLUMN …

ALTER   TABLE … ALTER COLUMN …

删除字段

ALTER   TABLE … DROP COLUMN

ALTER   TABLE … DROP COLUMN …

ALTER   TABLE … DROP …

ALTER   TABLE … DROP …

 

创建表

CREATE   TABLE … ()

CREATE   TABLE … ()

CREATE   TABLE … ()

CREATE   TABLE … ()

CREATE   TABLE … ()

创建普通索引

CREATE   INDEX … ON … ()

CREATE   INDEX … ON … ()

CREATE   INDEX … ON … ()

CREATE   INDEX … ON … ()

CREATE   INDEX … ON … ()

创建唯一索引

CREATE   UNIQUE INDEX … ON …()

CREATE   UNIQUE INDEX … ON …()

CREATE   UNIQUE INDEX … ON …()

CREATE   UNIQUE INDEX … ON …()

CREATE   UNIQUE INDEX … ON …()

删除索引

DROP   INDEX indexname

DROP   INDEX table.indexname

ALTER   TABLE … DROP INDEX indexname

DROP   INDEX indexname

DROP   INDEX indexname

 

其他:

DB Provider

SQL分页语法

JDBC URL Sample

Oracle

select   * from (select rownum r,t1.* from tableName t1 where 其他条件 and rownum <(当前页*每页行数+1) order by id) t2   where t2.r>((当前页-1)*每页行数)

oracle.jdbc.driver.OracleDriver

jdbc:oracle:thin:@192.168.0.3:1521:prj

SQLServer

select   * from (select rownum r,t1.* from tableName t1 where 其他条件 and rownum <(当前页*每页行数+1) order by id) t2   where t2.r>((当前页-1)*每页行数)

net.sourceforge.jtds.jdbc.Driver

jdbc:jtds:sqlserver://192.168.0.2:1433/finaltest;characterEncoding=gb2312

MYSQL

select   * from tableName t1 where 其他条件   order by id limit 返回记录行的偏移量,返回记录行的最大数目

偏移量起始值为0

com.mysql.jdbc.Driver

jdbc:mysql://localhost:3306/aws40_test1?characterEncoding=gb2312

Oscar

select * from   tableName t1 where 其他条件   order by id limit count OFFSET offset

count至多返回count行

offset在开始返回第一行之前要忽略的行数

com.oscar.Driver

jdbc:oscar://localhost:2003/osrdb

DB2

SELECT   * FROM (Select rownumber() over() as row,taball.* from ( select * from tableName   where 其他条件 order by   id) as taball) AS tabpage WHERE tabpage.row BETWEEN 起始行数 AND 结束行数

com.ibm.as400.access.AS400JDBCDriver

jdbc:as400://172.16.16.7/AWS

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/11376987.html