oracle学习笔记(2)

2019-04-08 18:18

alter table child_talbe_name drop constrints fk_name cascade ;

2、 视图 建视图

create view view_name as

select * from table_name 删除视图

drop view view_name 3、 快照 建快照

create snapshot snapshot_name build immediate

using index tablespace ?tablespace_name? storage (initial 12k next 12k pctincrease 10) refresh [complete/force/fast] with [rowed/primary key] using local rollback segment “rbs0” on [commit/demand] for update as select * from table_name

4、 索引

create index index_name on table table_name(field1,field2) ; drop index index_name ; 5、 簇

create cluster cluster_name (val type ) size 100 storage ( )

[index][hashkeys 200] ;

create table tab_1 ( field1 type ……)

cluster cluster_name ;

6、 序列

create sequence sequence_name increment by 1 start with 1 maxvalue 1024 minvalue 1 nocycle/cycle cache 22 noorder/order 7、 同义词

create synonym synonym_name for view/table ; create synonym synonym_name for view/table@

8、 数据连接

Create database link link_name connect to user_name identified by password using ?nstude? 9、 存储过程

create[or replace] procedure procdure_name ( <参数1> in/out , …… ) is | as

内部变量1 type; 内部变量2 type; begin …… end

运行: execute procdure_name 查看参数 print 参数1

10、 分区 create table table_name( field1 type ,

field2 type ) partition by range (field1)

( partition part1 values less than (value )

tablespace tableapace_name1, partition part1 values less than (value )

tablespace tableapace_name2, partition part1 values less than (value ) tablespace tableapace_name3 )

11、 函数

create [or replace] function function_name ( <参数1> in/out , …… )

return type is | as

内部变量1 type; 内部变量2 type; begin …… end

execute value := function_name(参数1) ;

12、 触发器

13、 包

二、数据库安全 1、 角色

create role role_name not identified

create role role_name identified by password create role role_name identified externally create role role_name identified globally grant 权限 to role_name ;

2、 用户 建立用户:

create user user_name profile “default” identified by “password”

default tablespace tablespace_name temporary tablespace temp_tablespace_name account unlock 修改用户:

alter user user_name

三、数据存储 1、 表空间

create tablespace tablespace_name

logging datafile 'D:\\ORACLE\\ORADATA\\ORASTUDY\\TEST.ora' size 5M default storage (initial 10k next 10k pctincrease 20)

alter tablespace tablespace_name default storage (initial 40k) alter database rename file ?path\\filename.ora?to ?path1\\filename1.ora? alter database datafile ?path\\filename.ora? resize 7m

alter database tablespace_name minimum extent 25k alter database tablespace_name online

alter database tablespace_name offline [normal/temporary/immediate] 注:normal/temporary/immediate 三个参数的选择参考 p295

2、 回滚段

create rollback segment rollback_name tablespace “RBS”

storage ( INITIAL 10K NEXT 10K OPTIMAL 13K MINEXTENTS 5 MAXEXTENTS 120) alter rollback segment rollback_name online alter rollback segment rollback_name offline

注 表空间建好后是离线的,需要将其改为在线。

3、 归档重做日志组 增加日志组

alter database add logfile group n (?path\\logn.ora?)size 1024k 修改日志组

alter database rename file (?path\\logn.ora?) to (?other_path\\ other_logn.ora?) 增加日志组成员

alter database add logfile member ?path\\name_file.ora?to group n

四、备份与回复 exp imp (一)冷备份: 1、 关闭数据库 2、 创建备份路径

3、 copy 数据文件、控制文件、系统初始化文件。 4、 打开数据库。 (二)热备份:

1、 转换到归档模式下 。 connect internal archive log start

查看归档模式的状态:archive log list 2、置为备份状态。

Alter tablespace temp begin backup 3、copy 数据文件

$ copy path1\\name1 path2\\name2 ; 5、 结束备份

alter tablespace temp end backup

6、 设置系统检测点 alter system checkpoint 6、备份控制文件

alter database backup controlfile to path\\name 7、关闭archive log archive log stop

(三)数据回复

用 V$log_history 可查看日志文件信息: RECID STAMP

THREAD# 线程号 SEQUENCE# 序列号 FIRST_CHANGE# 第一次变化号 FIRST_TIME 第一次变化时间 NEXT_CHANGE# 最后一次变化时间 1、不完全回复

1)基于时间点的不完成回复 connect internal startup mount

recover database until time ?02/19/99 12:43:55?; alter database open 2)基于变化号码的不完成回复 connect internal startup mount

recover database until change 12345 ; alter database open 3)基于停止的恢复 connect internal startup mount

recover database ;

(当提示:= suggest | filename | auto | cancel )作出相应的选择 alter database open ;

2、 完全恢复 connect internal startup mount

recover database alter database open 3、 仅对表空间回复

recover tablespace tablespace_name alter database open 4、 联机恢复

当数据库工作在archive模式下,当system表空间没有损坏,方可进行联机恢复。 Alter tablespace tablespace_name offline ; Recover tablespace tablespace_name ; Alter tablespace tablespace_name online ; 5、 回滚段恢复

create rollback segment rollback_name tablespace tablespace_name ;

savepoint savepoint_8

rollback to savepoint_8


oracle学习笔记(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:阿司匹林的合成论文

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: