select insert update delete merge
create alert drop truncate
commit rollback savepoint
grant revoke
1.字符类型 2.数字类型 3.日期类型 4.二进制及大文本数据
参考:Oracle 数据类型转换
1、查看当前用户,可以在 SQL Plus中执行下面语句 select user from dual;
2、用来调用系统函数
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;--获得当前系统时间
select SYS_CONTEXT('USERENV','TERMINAL') from dual;--获得主机名
select SYS_CONTEXT('USERENV','language') from dual;--获得当前 locale
select dbms_random.random from dual;--获得一个随机数
3、得到序列的下一个值或当前值,用下面语句
select your_sequence.nextval from dual;--获得序列your_sequence的下一个值
select your_sequence.currval from dual;--获得序列your_sequence的当前值
4、可以用做计算器 select 7*9 from dual;
参考:Oracle数据库常用函数
参考:彻底理解Oracle中的集合操作与复合查询
参考:ORACLE复杂查询之子查询
-- 创建表
create table table > as select * from <exists table>
-- 插入表
insert into table2(f1, f2...) select v1,v2... from table1
-- merge into 用法
merge into 表A
using xxx
on 和表A关联
when matched then
update set...
when not matched then
insert(...) value(...)
-- 递归查询
select * from table1 where xxx
start with (从某个节点开始)
connect by prior(子节点id和父节点pid直接的关系需要)
索引分为B树索引和位图索引。
参考:各种Oracle索引类型介绍
首先要对索引进行分析:
analyze index ind_1 validate structure; ind_1为你自己建立的索引
分析后查询几个主要的参数判断是否需要整理碎片:
select name,HEIGHT,PCT_USED,DEL_LF_ROWS/LF_ROWS from index_stats;
这里主要通过几个标准来判断是否需要整理碎片:
1.HEIGHT>=4
2.PCT_USED<50%
3.DEL_ROWS/LF_ROWS>0.2
如果查询到的值符合以上三种情况的任意一种,就说明我们需要进行碎片整理工作了。
碎片整理语句:
alter index ind_1 rebuild [online] [tablespace name];
一般情况下都是要加上online参数的,不必加tablespace name。
参考:
1.Oracle物化视图的一般使用
2.fast物化视图的刷新方式
参考:oracle同义词
参考:Oracle之Dblink
参考:oracle分区技术提高查询效率