ORACLE 的维护工作主要有打开和关闭数据库 用exp imp命令做逻辑备份 用t ar命令做物理备份 ORACLE 数据库使用一段时间后的空间扩张和针对具体的工作 增加临时或回滚表空间 取消新增的临时或回滚表空间 增加oracle的用户 给 用户授权等 以下按顺序详细介绍这
ORACLE 的维护工作主要有打开和关闭数据库
ar命令做物理备份
增加临时或回滚表空间
用户授权等
一
①
②
等待十几秒左右
oracle instances started
database mounted
database opened的时候
第二步的操作由如下命令组成
%svrmgrl 唤醒SVRMGR状态
SVRMGR >connect internal 连接内核
SVRMGR>startup 打开数据库
SVRMGR>exit
%
备注
SVRMGR> startup nomount 仅启动instances
SVRMGR> startup mount 启动instances
SVRMGR> startup normal 启动instances
打开(open)数据库
startup缺省参数是normal
③
如果出错检查环境变量是否设好
①
②
③
等待几秒左右
database closed
database dismounted
oracle instances shut down的时候
第三步的操作由如下命令组成
%svrmgrl 唤醒SVRMGR状态
SVRMGR>connect internal 连接内核
SVRMGR>shutdown 关闭数据库
SVRMGR>exit
%
备注
SVRMGR> shutdown abort 非正常立刻关机
SVRMGR> shutdown immediate 做回滚操作
SVRMGR> shutdown normal 正常关机
shutdown缺省参数是normal
二
基本命令
% exp user/password í
exp 模式
①
括cluster定义
②
export 示例 user mode
③
exp
export 示例
A
% exp system/manager
enter array fetch buffer size :
export file :expdat
e(ntire database)
export grants (y/n):y>y
export table data (y/n):y>y
compress extents(y/n):y>y
B
% exp system/manager
enter array fetch buffer size :
export file :expdat
e(ntire database)
export grants (y/n):y>y
export table data (y/n):y>y
compress extents(y/n):y>y
About to exp specified tables
Table to be exported (RETURN quit) > emp ( 输入要输出的表名 )
About to exp specified tables
Table to be exported (RETURN quit) > 如此循环下去
前提
才能使用export
权限
的表
_full_database角色)
字符
基本命令
% imp user/password
imp 模式
①
②
③
imp
import 示例
imp system/manager
import file :expdat
enter insert buffer size (minimum is
export file created by export:v
list contents of import file only(yds /no):no>
ignore create error due to obyict existence (yes /no):yes >
import grants (yes /no):yes>
import table data (yes /no):yes >
import entire export file (yes /no):yes >no
注意事项
①
②
和 import有时不会成功
③
三
把oracle 路径下所有文件备份到磁带机上
把备份磁带上所有文件恢复进oracle 当前路径
查看磁带上有些什么文件
四
当我们要开发某个大型的应用程序时
命令示例
SVRMGR>create tablespace application datafile
针对具体情况增加回滚和临时表空间
命令示例
SVRMGR>create rollback tablespace rbs
SVRMGR>create tablespace tmp
回滚和临时表空间用完后
SVRMGR>drop tablespace rbs
SVRMGR>drop tablespaces tmp
SVRMGR>alter tablespace rbs offline;
SVRMGR>alter tablespace tmp
建立回滚段举例
SVRMGR>create rollback segment rs
SVRMGR>alter rollback segment rs
SVRMGR>alter rollback segment rs
当一个表空间的大小不能满足工作需要时
举例
SVRMGR>alter tablespace system
add datafile
五
举例
SVRMGR>create user newuser identified by userpasswd
default tablespace application
temporary tablespace tmp
SVRMGR>grant connect to newuser;
SVRMGR>grant resource to newuser;
SVRMGR>grant update on emp to newuser;
oracle的缺省角色有connect
或用户的权限总和
个权限
只有数据库管理员才有dba的权限
①创建一个角色
SVRMGR>create role newrole identified by rolepa