备份:
备份全库:
RMAN> backup database format '/backup/fulldb/%U';
RMAN> list backup of database;
备份表空间:
RMAN> backup tablespace tbs_pb_dparam;
Starting backup at 20121214152625
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00110 name=/oradata/orcl/TBS_PB_DPARAM_01.dbf
channel ORA_DISK_1: starting piece 1 at 20121214152625
channel ORA_DISK_1: finished piece 1 at 20121214152626
piece handle=/s01/fast_recovery_area/ORCL/backupset/2012_12_14/o1_mf_nnndf_TAG20121214T152625_8doo51q2_.bkp tag=TAG20121214T152625 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 20121214152626
RMAN> list backup of tablespace tbs_pb_dparam;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
9 Full 82.55M DISK 00:00:07 20121214151355
BP Key: 9 Status: AVAILABLE Compressed: NO Tag: TAG20121214T151204
Piece Name: /backup/fulldb/0dnsrm9c_1_1
List of Datafiles in backup set 9
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- -------------- ----
110 Full 2515132 20121214120212 /oradata/orcl/TBS_PB_DPARAM_01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
11 Full 1.03M DISK 00:00:00 20121214152625
BP Key: 11 Status: AVAILABLE Compressed: NO Tag: TAG20121214T152625
Piece Name: /s01/fast_recovery_area/ORCL/backupset/2012_12_14/o1_mf_nnndf_TAG20121214T152625_8doo51q2_.bkp
List of Datafiles in backup set 11
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- -------------- ----
110 Full 2515132 20121214120212 /oradata/orcl/TBS_PB_DPARAM_01.dbf
有2个备份集,删除其中一个:
RMAN> delete backupset 11;
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
11 11 1 1 AVAILABLE DISK /s01/fast_recovery_area/ORCL/backupset/2012_12_14/o1_mf_nnndf_TAG20121214T152625_8doo51q2_.bkp
Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/s01/fast_recovery_area/ORCL/backupset/2012_12_14/o1_mf_nnndf_TAG20121214T152625_8doo51q2_.bkp RECID=11 STAMP=802020385
Deleted 1 objects
RMAN> list backup of tablespace tbs_pb_dparam;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
9 Full 82.55M DISK 00:00:07 20121214151355
BP Key: 9 Status: AVAILABLE Compressed: NO Tag: TAG20121214T151204
Piece Name: /backup/fulldb/0dnsrm9c_1_1
List of Datafiles in backup set 9
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- -------------- ----
110 Full 2515132 20121214120212 /oradata/orcl/TBS_PB_DPARAM_01.dbf
备份指定的数据文件:
RMAN> backup datafile 10;
Starting backup at 20121214153209
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00010 name=/oradata/orcl/TBS_ACT_DAPP_01.dbf
channel ORA_DISK_1: starting piece 1 at 20121214153209
channel ORA_DISK_1: finished piece 1 at 20121214153210
piece handle=/s01/fast_recovery_area/ORCL/backupset/2012_12_14/o1_mf_nnndf_TAG20121214T153209_8doohshb_.bkp tag=TAG20121214T153209 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 20121214153210
Starting Control File and SPFILE Autobackup at 20121214153210
piece handle=/s01/fast_recovery_area/ORCL/autobackup/2012_12_14/o1_mf_s_802008132_8doohv3w_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 20121214153211
RMAN> list backup of datafile 10;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
9 Full 82.55M DISK 00:00:07 20121214151355
BP Key: 9 Status: AVAILABLE Compressed: NO Tag: TAG20121214T151204
Piece Name: /backup/fulldb/0dnsrm9c_1_1
List of Datafiles in backup set 9
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- -------------- ----
10 Full 2515132 20121214120212 /oradata/orcl/TBS_ACT_DAPP_01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
13 Full 1.03M DISK 00:00:00 20121214153209
BP Key: 13 Status: AVAILABLE Compressed: NO Tag: TAG20121214T153209
Piece Name: /s01/fast_recovery_area/ORCL/backupset/2012_12_14/o1_mf_nnndf_TAG20121214T153209_8doohshb_.bkp
List of Datafiles in backup set 13
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- -------------- ----
10 Full 2515132 20121214120212 /oradata/orcl/TBS_ACT_DAPP_01.dbf
由于执行了 :configure controlfile autobackup on; 所以每次都会备份控制文件。
手动备份控制文件:
RMAN> backup current controlfile;
Starting backup at 20121214153444
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 20121214153446
channel ORA_DISK_1: finished piece 1 at 20121214153447
piece handle=/s01/fast_recovery_area/ORCL/backupset/2012_12_14/o1_mf_ncnnf_TAG20121214T153444_8doonp47_.bkp tag=TAG20121214T153444 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 20121214153447
Starting Control File and SPFILE Autobackup at 20121214153447
piece handle=/s01/fast_recovery_area/ORCL/autobackup/2012_12_14/o1_mf_s_802008132_8doonr4f_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 20121214153450
备份spfile文件:
RMAN> backup spfile;
Starting backup at 20121214154008
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 20121214154009
channel ORA_DISK_1: finished piece 1 at 20121214154010
piece handle=/s01/fast_recovery_area/ORCL/backupset/2012_12_14/o1_mf_nnsnf_TAG20121214T154008_8dooys25_.bkp tag=TAG20121214T154008 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
同义词概念
Oracle的同义词(synonyms)从字面上理解就是别名的意思,和视图的功能类似,就是一种映射关系。它可以节省大量的数据库空间,对不同用户的操作同一张表没有多少差别;它扩展了数据库的使用范围,能够在不同的数据库用户之间实现无缝交互;Oracle数据库中提供了同义词管理的功能。同义词是数据库对象的一个别名,经常用于简化对象访问和提高对象访问的安全性。在使用同义词时,Oracle数据库将它翻译成对应方案对象的名字。与视图类似,同义词并不占用实际存储空间,只有在数据字典中保存了同义词的定义。在Oracle数据库中的大部分数据库对象,如表、视图、物化视图、序列、函数、存储过程、包、同义词等等,数据库管理员都可以根据实际情况为他们定义同义词。
同义词分类
Oracle同义词有两种类型,分别是Oracle公用同义词与Oracle私有同义词。普通用户创建的同义词一般都是私有同义词,公有同义词一般由DBA创建,普通用户如果希望创建同义词,则需要CREATE PUBLIC SYNONYM这个系统权限。
1)Oracle公用同义词:由一个特殊的用户组Public所拥有。顾名思义,数据库中所有的用户都可以使用公用同义词。公用同义词往往用来标示一些比较普通的数据库对象,这些对象往往大家都需要引用。
2)Oracle私有同义词:它是跟公用同义词所对应,他是由创建他的用户所有。当然,这个同义词的创建者,可以通过授权控制其他用户是否有权使用属于自己的私有同义词。
同义词作用
1) 多用户协同开发中,可以屏蔽对象的名字及其持有者。如果没有同义词,当操作其他用户的表时,必须通过user名.object名的形式,采用了Oracle同义词之后就可以隐蔽掉user名,当然这里要注意的是:public同义词只是为数据库对象定义了一个公共的别名,其他用户能否通过这个别名访问这个数据库对象,还要看是否已经为这个用户授权。
2) 为用户简化sql语句。上面的一条其实就是一种简化sql的体现,同时如果自己建的表的名字很长,可以为这个表创建一个Oracle同义词来简化sql开发。
3)为分布式数据库的远程对象提供位置透明性。
4)Oracle同义词在数据库链接中的作用
数据库链接是一个命名的对象,说明一个数据库到另一个数据库的路径,通过其可以实现不同数据库之间的通信。
Create database link 数据库链名 connect to user名 identified by 口令 using ‘Oracle连接串’; 访问对象要通过 object名@数据库链名。同义词在数据库链中的作用就是提供位置透明性。
同义词权限管理
与同义词相关的权限有CREATE SYNONYM、CREATE ANY SYNONYM、CREATE PUBLIC SYNONYM权限。
1:用户在自己的模式下创建私有同义词,这个用户必须拥有CREATE SYNONYM权限,否则不能创建私有同义词。
如下所示,用户DM缺少CREATE SYNONYM权限,创建同义词时会报ORA-01031错误
SQL> CREATE SYNONYM TEST FOR DM.TM_WGG_ATM_GTW_MON;CREATE SYNONYM TEST FOR DM.TM_WGG_ATM_GTW_MON
ORA-01031: insufficient privileges
用sys账号给DM账号赋予CREATE SYNONYM的权限
Grant succeeded.
然后创建私有同义词
Synonym created
2:如果需要在其它模式下创建同义词,则必须具有CREATE ANY SYNONYM的权限。
看下面的例子
用户DM想创建SCOTT模式下的私有同义词
CREATE SYNONYM SCOTT.EM FOR SOCTT.EMP
ORA-01031: insufficient privileges
创建表空间:
create tablespace liwg_test
datafile '/oradata/test/liwg01.dbf' size 50m,
'/oradata/test/liwg02.dbf' size 50m
online
minimum extent 100k
default storage(
initial 100k
next 100k
minextents 2
maxextents 50
pctincrease 0);
本文链接