Oracle SQL总结
统计前15天日期
select
to_char( ( sysdate - rownum + 1 ), 'yyyy-MM-dd' ) as day
from
user_objects
where
rownum < 15
查看执行计划
explain plan for select * from user_objects;
select * from table(dbms_xplan.display);
临时表
with
temp1 as (select * from user),
temp2 as (select * from xxx),
temp2 as (select * from xxx)
select * from temp1,temp2,temp3;
日期格式化
select to_date('2021-03-18 22:48:06', 'yyyy-MM-dd hh24:mi:ss') from dual;
select to_char(sysdate, 'yyyy-MM-dd') from dual;
截取指定字符串
select substr('hello, world!', 0, 5) from dual;
拼接字符串
select concat('hello', ' ', 'world') as greeting from dual;