首页 > 数据库 >Oracle转PostgreSQL

Oracle转PostgreSQL

时间:2023-01-04 03:44:48浏览次数:57  
标签:PostgreSQL sc ID test Oracle where id select

Oracle转PostgreSQL

Oracle postgresql oracle sql 数据库
 

最近在做一些Oracle SQL转PostgreSQL的工作,顺便记录这些改变,以便以后再转换有个参考。

描述OraclePostgreSQL
分页 select * from ( select z.*,rownum as num from( " + sql + " ) z ) where num>=" + startRow + " and num<=" + endRow select z.* from ( " + sql + " ) z LIMIT " + pageSize + " OFFSET " + startRow
日期 ① select sysdate from dual
② select t.* from test_user t where sysdate < t.end_date +1
③ select t.* from test_user t where now() < date_trunc('day',t.end_date) + interval '1d'
④ select * from test_user where round(pwd_eff_date+pwd_eff_days-now())>0
① select now();
② select t.* from test_user t where now() < date_trunc('day',t.end_date) + interval '1d'
③ select trunc(date_trunc(‘day’,now()) - interval ‘60d’)
④ select * from test_user where (pwd_eff_date + (interval '1d' * pwd_eff_days))::date - now()::date >0
DB <driverClassName>oracle.jdbc.OracleDriver</driverClassName> <url>jdbc:oracle:thin:@192.168.1.1:1521:testdb</url> <driverClassName>org.postgresql.Driver</driverClassName> <url>jdbc:postgresql://192.168.1.1:5432/testdb</url>
序列 test_seq_log.nextval nextval(‘test_seq_log’)
别名 ① update test_user t set t.test_username=‘123456’
② select * from (select * from TEST_STAFF where staff_id = ? or employee_id = ?) where status=‘1’
① update test_user set test_username='123456’
② select * from (select * from TEST_STAFF where staff_id = ? or employee_id = ?) result where status=‘1’
Row select t.*, t.rowid from test_user t select t.*, t.ctid from test_user t
日期    
nvl select DISTINCT * from test_feature t where nvl(t.parent_id,0)=0 select DISTINCT t.* from test_feature t where coalesce(t.parent_id,0)=0
分组 SELECT COUNT(*) FROM ET_CHOICEITEM WHERE QUE_ID = 60421 ORDER BY ITEM_ID SELECT COUNT(*) FROM ET_CHOICEITEM WHERE QUE_ID = 60421 ORDER BY ITEM_ID
  select sc.*,s.*,c.*,r.* from test_staffcourse sc,test_staff s,test_course c,test_result r where sc.training_id=s.training_id and sc.course_id=c.course_id and r.training_id(+)=sc.training_id and r.COURSE_ID(+)=sc.course_id select sc.*,s.*,c.*,r.* from test_staffcourse sc join test_staff s on sc.training_id=s.training_id join test_course c on sc.course_id=c.course_id left join test_result r on r.training_id=sc.training_id and r.COURSE_ID=sc.course_id
     
connect by prior select distinct * from TEST_FEATURE connect by prior PARENT_ID=FEATURE_ID start with FEATURE_ID in (11, 12) order by FEATURE_ID select a.* from TEST_FEATURE a where a.FEATURE_ID in (11, 12) union all select distinct * from TEST_FEATURE b where b.FEATURE_ID in (select distinct c.parent_id from TEST_FEATURE c where c.FEATURE_ID in (11, 12)) order by FEATURE_ID
Decode decode(sign(decode(sc.last_result,null,90000,0,9000,-1,90000,sc.last_result)-c.pass_mark),-1,0,1)=1) case when sign(case when sc.last_result=null then 90000 when sc.last_result=0 then 9000 when sc.last_result=-1 then 90000 else sc.last_result end - c.pass_mark) = -1 then 0 else 1 end = 1)
Rownum SELECT ROWNUM, empno, ename, job FROM emp WHERE ROWNUM < 5 ORDER BY ename; select row_number() over () as rownum, * from emp limit 10 offset 5;

复制表结构:

create table test_user_backup_20210223 as
( select * from test_user)
 

标签:PostgreSQL,sc,ID,test,Oracle,where,id,select
From: https://www.cnblogs.com/yaoyangding/p/17023836.html

相关文章

  • PostgreSQL动态SQL(兼容oracle DBMS_SQL)
    PostgreSQL动态SQL(兼容oracleDBMS_SQL)PostgreSQL sql 数据库 postgresql oracle中的dbms_sql包可以用来执行动态SQL,让我们在存储过程的动态SQL中使用prepared......
  • postgresql windows 开发环境搭建
    postgresqlwindows开发环境搭建发布时间:2020-06-2912:45:05 来源:网络 阅读:2883 作者:pgmia 栏目:数据库一、软件需求Windows7旗舰版sp1X64ActivePerl-5.......
  • PostgreSQL兼容oracle rman备份——pg_rman
    PostgreSQL兼容oraclerman备份——pg_rmanPostgreSQL sql 数据库 postgresql 0、说明PostgreSQL支持多种备份数据的方式,如:SQL转储、文件系统级备份、连续归档。......
  • PostgreSQL citus python环境搭建
    PostgreSQLcituspython环境搭建 精选 原创Janeh10182022-01-0809:19:09博主文章分类:PostgreSQL©著作权文章标签sqlpostgresql数据库文章分类其它数据库阅读数27......
  • postgresql内核开发之Oracle date类型兼容
    postgresql内核开发之Oracledate类型兼容postgresql内核开发 postgresql兼容oracle postgresql 数据库 oracle兼容 开发实战         ORACLE......
  • postgres oracle 兼容,PostgreSQL Oracle 兼容性之 - sys_guid() UUID
    postgresoracle兼容,PostgreSQLOracle兼容性之-sys_guid()UUIDpostgresoracle兼容 背景Oracle使用sys_guid()用来产生UUID值。在PostgreSQL中有类似的......
  • spring整合Mybatis | Postgresql为例
    1.创建配置文件jdbc.propertiesjdbc.url=jdbc:postgresql://localhost:5432/postgis_hy?useSSL=falsejdbc.username=postgresjdbc.password=arcgis2.相关依赖<de......
  • [Oracle19C 数据库管理] dbca silent创建数据库
    创建的数据库的GlobalDatabaseName是CDBTEST,实例名字是CDBTEST.多租户CDB,带一个PDB叫做PDB1.带有范例数据库hr。字符集AL32UTF8。实例对应的LISTENER是LISTENER1......
  • 4.Oracle的执行计划
    1.Oracle的执行计划  执行计划:描述一条语句在oracle中的执行过程或访问路径的描述,即就是对一个查询任务,做出一个怎样去完成任务的详细方法如果要分析某条sql的性......
  • postgresql用sql查询表结构
      查询sql如下:SELECTa.attnameASfield,t.typnameAStype,CASEWHENt.typlen=-1THENa.atttypmod-4ELSEt.typlen::integerENDASlengthvar,casea.......