博客
关于我
[oracle] 学习_持续更新
阅读量:395 次
发布时间:2019-03-05

本文共 2535 字,大约阅读时间需要 8 分钟。

Oracle 教程目录(自学指南)

1. 创建与管理表

1.1 创建表

create table TEST_PARA (    name        VARCHAR2(100) not null,    sql         CLOB,    create_time DATE);

1.2 修改字段长度

alter table WX_INVOICES modify shop_director_tel varchar2(50);

1.3 管理序列

-- 创建序列create sequence SEQ_TABLE     minvalue 1     maxvalue 999999999999999999999999999     start with 15     increment by 1     nocache;-- 查询序列下一个值select SEQ_TABLE.nextval from dual;-- 删除序列drop sequence SEQ_TABLE;

2. 动态 SQL 与强制执行

2.1 动态 SQL 应用

execute immediate ('TRUNCATE TABLE TABLE'); -- 动态执行存储过程V_SQL = 'BEGIN PROC(I_YF,O_RET_CODE,O_RET_NOTE);END;';execute immediate V_SQL using (IN) I_YF, (OUT) O_RET_CODE, (OUT) O_RET_NOTE;-- 动态检索数据execute immediate 'select count(1) from table' into v_sql;execute immediate 'insert into table (int) values (:X)' using i;

2.2 截取日期年月日

select     to_date('201904', 'YYYYMM') as date_str,    extract(year from to_date('201904', 'YYYYMM')) as year,    extract(month from to_date('201904', 'YYYYMM')) as month,    extract(day from to_date('201904', 'YYYYMM')) as day,    extract(year from sysdate) as year_sys,    extract(month from sysdate) as month_sys,    extract(day from sysdate) as day_sys,    extract(year from date '2015-05-04') as year_date,    extract(month from date '2015-05-04') as month_date,    extract(day from date '2011-05-04') as day_datefrom dual;

3. 循环与字符串操作

3.1 FOR 循环

for x in 1..v_cnt loop    -- 循环体end loop;

3.2 行转列

select     reg_replace('xxyyzziioo', 'xx|zz|oo$', '') from dual;

4. 数据验证与转换

4.1 手机格式验证

select     max(1) as flag from dual where regexp_like(:MOBILE, '^[1]{1}[3456789]{1}[[:digit:]]{9}$');

5. 数据排序与统计

5.1 取最大值或最小值

select     max(a.column) keep(dense_rank last order by a.column) from table a;

6. 查看系统信息

6.1 查看外键关联表

select * from user_constraints cc where cc.r_constraint_name in (    select c.r_constraint_name     from user_constraints c     where c.constraint_type = 'R'     and c.constraint_name = 'FK_MT_SCH_L_REFERENCE_MT_SCH');

7. 事务管理与优化

7.1 数据库回退

flashback table ecif.TJG_DX to timestamp to_timestamp('2017-09-05 12:30:00', 'YYYY-MM-DD HH24:mi:ss');

8. 特殊字符处理

8.1 去空格与回车

select     ltrim(rtrim(replace(replace('qwe123', chr(10), ''), chr(13), '')) from dual;

9. 触发器应用

9.1 创建触发器

create or replace trigger Temptable_TESTbefore insert or update on Temptable_TESTfor each rowwhen (old.n1 > 100)begin    insert into Temptable_TEST_his (C1, C2) values ('de_trig', :old.c2);end;

10. 树遍历结构

10.1 树结构查询

select id from lborganizationconnect by prior id = fidstart with id = ***;

以上内容为Oracle数据库管理的实用指南,涵盖了从基础操作到高级功能的多个方面,旨在为学习者提供全面的学习资源。

转载地址:http://trdzz.baihongyu.com/

你可能感兴趣的文章
OSG学习:几何体的操作(一)——交互事件、简化几何体
查看>>
OSG学习:几何体的操作(二)——交互事件、Delaunay三角网绘制
查看>>
OSG学习:几何对象的绘制(一)——四边形
查看>>
OSG学习:几何对象的绘制(三)——几何元素的存储和几何体的绘制方法
查看>>
OSG学习:几何对象的绘制(二)——简易房屋
查看>>
OSG学习:几何对象的绘制(四)——几何体的更新回调:旋转的线
查看>>
OSG学习:场景图形管理(一)——视图与相机
查看>>
OSG学习:场景图形管理(三)——多视图相机渲染
查看>>
OSG学习:场景图形管理(二)——单窗口多相机渲染
查看>>
OSG学习:场景图形管理(四)——多视图多窗口渲染
查看>>
OSG学习:新建C++/CLI工程并读取模型(C++/CLI)——根据OSG官方示例代码初步理解其方法
查看>>
Sql 随机更新一条数据返回更新数据的ID编号
查看>>
OSG学习:空间变换节点和开关节点示例
查看>>
OSG学习:纹理映射(一)——多重纹理映射
查看>>
OSG学习:纹理映射(七)——聚光灯
查看>>
OSG学习:纹理映射(三)——立方图纹理映射
查看>>
OSG学习:纹理映射(二)——一维/二维/简单立方图纹理映射
查看>>
OSG学习:纹理映射(五)——计算纹理坐标
查看>>