mysql语句转为oracle语句

mysql建表语句转为oracle建表语句java


单引号'变双引号"mysql

comment内容去掉sql

varchar变varchar2数据库

double/int之类的数字变numberoracle

PRIMARY KEY  ("kc_no")语句变 CONSTRAINT "kc_no" PRIMARY KEY  ("kc_no")字符串


select jihua_no from zhou.px_kecheng_jihua get

where status<>-1 input

and input_date between "0001-01-01" and "9999-12-31" date

order by input_date descselect

mysql语句转为oracle语句日期再也不是字符串须要to_date

select jihua_no from px_kecheng_jihua 

where status<>-1 

and input_date between to_date('0001-01-01','yyyy-mm-dd') and to_date('9999-12-31','yyyy-mm-dd')

order by input_date desc



用java设置日期

            pStmt.setDate(13,new java.sql.Date(Calendar.getInstance().getTimeInMillis()));

            pStmt.setDate(14,new java.sql.Date(order.getPxDate().getTime()));


驱动程序名称

MySQL-AB JDBC Driver

Oracle JDBC driver

能够经过

conn.getMetaData().getDriverName().contains("MySQL")判断是何数据库

例如:

 if(conn.getMetaData().getDriverName().contains("MySQL")==true)

                sqlStr="select jihua_no from px_kecheng_jihua where status<>-1 and "+column+" like ? and input_date between ? and ? order by input_date desc";

            if(conn.getMetaData().getDriverName().contains("Oracle")==true)

                sqlStr="select jihua_no from px_kecheng_jihua where status<>-1 and "+column+" like ? and input_date between to_date(?,'yyyy-mm-dd') and to_date(?,'yyyy-mm-dd') order by input_date desc";

相关文章
相关标签/搜索