Oracle相关语法问题

jdbc连接Oracle

最近使用jdbc连接oracle时报错:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor The Connection descriptor used by the client was:

转载博客:
https://www.cnblogs.com/651434092qq/p/11209240.html

Oracle 到 Hive 的数据类型映射


oracle sql topN查询及分页查询

  • 查询前十条数据
-- oracle sql 查询前十条数据
select * from b2c_code where rownum <= '10';
  • 分页查询
SELECT *
  FROM (SELECT a.*, ROWNUM rn
          FROM (SELECT *
                  FROM table_name) a
         WHERE ROWNUM <= 40)
WHERE rn >= 21

oracle在where子句中加(+) 什么意思

select * from a,b
where a.id=b.id(+)// 左连接

a表显示全部,b表id和a表id匹配,匹配不上的null填充。

左条件 = 右条件(+) 也称为左外连接;
左条件(+) = 右条件 也称为右外连接。

oracle--trunc与to_char的区别

trunc取得是天(可比较),而to_char取得是数值(可计算):
但trunc(date) 具有与to_char(date) 相似的功能,但有区别


trunc(sysdate,'cc')   取当世纪的第一天     to_char(sysdate,'cc')   取当世纪数值
trunc(sysdate,'yyyy') 取当年的第一天       to_char(sysdate,'yyyy') 取当年数值
trunc(sysdate,'iyyy') 取上年的最后一天     to_char(sysdate,'iyyy') 取当年数值
trunc(sysdate,'Q')    取当季第一天         to_char(sysdate,'Q') 取当季数值
trunc(sysdate,'mm')   取当月第一天         to_char(sysdate,'mm')   取当月数值
trunc(sysdate,'ww')   取当周第一天(周二)   to_char(sysdate,'ww')   取当周数值(第几周)
trunc(sysdate,'iw')   取当周第一天(周一)   to_char(sysdate,'iw')   取当周数值(第几周)
 
--当季
select  to_char(sysdate,'Q') from dual
select  trunc(sysdate,'Q')  from dual
--当月
select  trunc(sysdate,'mm')  from dual
select  to_char(sysdate,'mm') from dual
-- 当天
select  to_char(sysdate,'dd') from dual
select  trunc(sysdate,'dd') from dual
作者:落花桂
         
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/nthforsth/p/15021446.html