博客
关于我
[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/

你可能感兴趣的文章
Orleans框架------基于Actor模型生成分布式Id
查看>>
SQL-36 创建一个actor_name表,将actor表中的所有first_name以及last_name导入改表。
查看>>
ORM sqlachemy学习
查看>>
Ormlite数据库
查看>>
orm总结
查看>>
os.environ 没有设置环境变量
查看>>
os.path.join、dirname、splitext、split、makedirs、getcwd、listdir、sep等的用法
查看>>
os.removexattr 的 Python 文档——‘*‘(星号)参数是什么意思?
查看>>
os.system 在 Python 中不起作用
查看>>
OS2ATC2017:阿里研究员林昊畅谈操作系统创新与挑战
查看>>
OSCACHE介绍
查看>>
SQL--合计函数(Aggregate functions):avg,count,first,last,max,min,sum
查看>>
OSChina 周五乱弹 ——吹牛扯淡的耽误你们学习进步了
查看>>
SQL--mysql索引
查看>>
OSChina 周四乱弹 ——程序员为啥要买苹果手机啊?
查看>>
OSChina 周日乱弹 —— 2014 年各种奇葩评论集合
查看>>
OSChina 技术周刊第十期,每周技术抢先看!
查看>>
OSError: no library called “cairo-2“ was foundno library called “cairo“ was foundno library called
查看>>
OSError: [WinError 193] %1 不是有效的 Win32 应用程序。
查看>>
osgearth介绍
查看>>