prompt 0 init env
set pagesize 99; set linesize 160;
prompt 1.demo for show data of date type on screen
select hiredate from emp; --nls_date_format --native language system --ALTER SYSTEM BY SYS --ALTER SESSION SET nls_language='AMERICAN'; ALTER SESSION SET nls_language='SIMPLIFIED CHINESE';
ALTER SESSION SET nls_date_format='yyyy/mon/dd'; select hiredate from emp; ALTER SESSION SET nls_date_format='yyyy/mm/dd hh:mi:ss'; --P163-P165 select hiredate from emp;
prompt 2.demo for show data of date type translateing to string on screen
column dateStr format a25; column weekdayStr format a20; column allStr format a40; ALTER SESSION SET nls_date_format='yyyy/mm/dd'; select hiredate, to_char(hiredate,'yyyy-month-dd') dateStr, to_char(hiredate,'day') weekdayStr, to_char(hiredate,'yyyy-month-dd day') allStr from emp;
prompt 3.demo for how to traslate string to date
ALTER SESSION SET nls_date_format='yyyy/mm/dd hh:mi:ss'; column dateType format a25; column rechangeStr format a25; select to_char(to_date('10:56','hh:mi'),'yyyy-mm-dd') rechangeStr from dual; --将10:56看成一个从服务器系统时间sysdate本月开始的偏移量
prompt 4.demo for tree query
--用顺序存储表达树状结构 column part_name format a20; select part_id, parent_id, part_name, mp_cost from bicycle start with part_id=1 connect by prior part_id =parent_id;
select part_id, parent_id, part_name, mp_cost from bicycle start with part_name='钢珠' connect by prior parent_id =part_id;
— 1 null 自行车
— 2 1 导向系统
–给定数据库,查指定结点的上级
–给定数据库,查指定结点的下级
select part_id, parent_id, part_name, mp_cost from bicycle start with part_id=1 connect by prior part_id =parent_id order by level; -- level
column partName format A35 column mp_cost format 99999.99 select level, lpad(' ', 4*(level-1)) || part_name as partName, mp_cost from bicycle start with part_id = 1 connect by prior part_id = parent_id;
column partName format A35 column mp_cost format 99999.99 select level, lpad(' ', 4*(level-1)) || part_name as partName, mp_cost from bicycle start with part_id = 1 connect by prior part_id = parent_id order by level;
prompt 5.demo for decode query
select ename, sal, deptno, decode(deptno, '10', '会计部', '其他部门') from emp; select ename, sal, deptno, decode(deptno, '10', '会计部', '20', '研发部', '30', '销售部', '其他部门') from emp; column actualCost format 999999.00; column translatedCost format a20; select part_name, mp_cost as actualCost, translate(mp_cost, 1234567890, 5129837046) as translatedCost from bicycle; select * from score where grade=98;
本站由以下主机服务商提供服务支持:
0条评论