随笔分类 - Oracle
摘要:核心提示:--行列转换 行转列DROP TABLE t_change_lc;CREATE TABLE t_change_lc (card_code VARCHAR2 --行列转换 行转列 DROP TABLE t_change_lc; CREATE TABLE t_change_lc (card_code VARCHAR2(3), q NUMBER, bal NUMBER); INSERT INTO t_change_lc SELECT '001' card_code, ROWNUM q, trunc(dbms_random.VALUE * 100) bal FROM dual
阅读全文
摘要:1 -- 1.rownum是oracle预处理字段,默认标序是1,只有记录集已经满足条件后才会进行后续编号,否则将一直为1。 2 -- 2.~ 3 4 select * from ( select e.*,rownum rn -- 起个别名,主要是给外层用的 5 from emp e 6 where rownum =4 -- 必须使用rn,不能使用rownum。若使用rownum,则默认为外层的rownum发生情况1(无数据)。 8 9 ------------------------------------------------...
阅读全文
摘要:ORACLE日期时间函数大全 TO_DATE格式(以时间:2007-11-02 13:45:25为例) Year: yy two digits 两位年 显示值:07 yyy three digits 三位年 显示值:007 yyyy four digits 四位年 显示值:2007 Month: mm number 两位月 显示值:11 mon abbreviated 字符集表示 显示值:11月,若是英文版,显示nov month spelled out 字符集表示 显示值:11月,若是英文版,显示november Day: dd number 当月第几天 显示值:02 ddd number
阅读全文
摘要:
阅读全文
摘要:insert all|first ---- ALL 符合条件的都插入, FIRST 只插入第一个符合条件的when sum_orders = 10000 and sum_orders < 100000 theninto medium_customerselseinto large_customersselect customer_id, sum(order_total) sum_ordersfrom oe.ordersgroup by customer_id;
阅读全文
摘要:-- Initializing LOB Columns Added to a Table-- 添加列alter table employees add (resume clob,picture blob);-- 初始化create table emp_hiredata( employee_id number(6), full_name varchar2(45), resume clob default empty_clob(), picture blob default empty_blob());
阅读全文
摘要:create procedure set_video(dir_alias varchar2,dept_id number) is filename varchar2(40); file_ptr BFILE; CURSOR emp_csr is select first_name from employees where department_id = dept_id for update;begin for rec in emp_csr loop filename := rec.first_name...
阅读全文
摘要:ORACLE PL/SQL编程之八:把触发器说透大家一定要评论呀,感谢!光发表就花了我将近一个下午。本篇主要内容如下:8.1触发器类型8.1.1DML触发器8.1.2替代触发器8.1.3系统触发器8.2创建触发器8.2.1触发器触发次序8.2.2创建DML触发器8.2.3创建替代(INSTEAD OF)触发器8.2.3创建系统事件触发器8.2.4系统触发器事件属性8.2.5使用触发器谓词8.2.6重新编译触发器8.3删除和使能触发器8.4触发器和数据字典8.5数据库触发器的应用举例触发器是许多关系数据库系统都提供的一项技术。在ORACLE系统里,触发器类似过程和函数,都有声明,执行和异常处理过
阅读全文
摘要:create procedure compile(pkg_name varchar2) is warn_value varchar2(200); compile_stmt varchar2(200) := 'alter package '|| pkg_name ||' compile';begin warn_value := ---- 保存当前设定 dbms_warning.get_warning_setting_string; dbms_warning.add_warning_setting_cat( -- 改变 ...
阅读全文
摘要:以例子学习with:with --查询部门和部门的总薪水 dept_costs as ( select d.department_name,sum(e.salary) dept_total from departments d,employees e where d.department_id=e.department_id group by d.department_name ), --利用上一个...
阅读全文
摘要:基本用法~~~~~~~~~~~~~~~~~~~~~~SELECT * FROM tree-- where 子句 , 若有,只是过滤最终结果的作用START WITH father = '爷爷' -- 从 father 为 '爷爷' 的 那一条记录开始-- 若有 nocyle 关键字, 则不走环, 仅列出所有映射CONNECT BY [NOCYCLE] PRIOR son = father; -- 你的 son 为 他人的 father, 搜索他人,即往下找实际例子~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~问题:数据库里有字段day_number
阅读全文

浙公网安备 33010602011771号