alter database [add|drop] logfile
alter database [add|drop] logfile member
alter database [add|drop] logfile group
alter database [noarchivelog|archivelog]
alter database rename file
create tablespace
alter tablespace [add|rename] datafile
alter tablespace [read write|read only]
drop tablespace
控制文件的备份,三种方式
1)使用OS命令进行拷贝
1)open状态下,使用alter database命令生成控制文件副本
2)open状态下,使用alter database backup controlfile to trace命令将控制文件备份到跟踪文件
控制文件的恢复,两种方式
1)mount状态下,使用RECOVER DATABASE USING BACKUP CONTROLFILE
2)mount状态下,生成跟踪文件并进行恢复
2–2示例:
SQL*Plus: Release 10.2.0.1.0 – Production on 星期一 8月 1 21:40:03 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 528482304 bytes
Fixed Size 1220360 bytes
Variable Size 176161016 bytes
Database Buffers 343932928 bytes
Redo Buffers7168000 bytes
Database mounted.
Database opened.
–open状态下生成控制文件副本
SQL> alter database backup controlfile to
2 ‘/oracle/10g/oracle/bakup/database/oralife.ctl’;
alter database backup controlfile to
*
ERROR at line 1:
ORA-01580: error creating control backup file
/oracle/10g/oracle/bakup/database/oralife.ctl
ORA-27038: created file already exists
Additional information: 1
SQL> alter database backup controlfile to
2 ‘/oracle/10g/oracle/bakup/database/oralife.ctl’ reuse; –reuse用于覆盖原有控制文件副本
Database altered.
–手动删除所有控制文件模拟文件丢失
SQL> ho rm /oracle/10g/oracle/product/10.2.0/oradata/oralife/*.ctl;
–使用evan登录,并添加数据
SQL> conn evan/evan
Connected.
SQL> select * from t_evan;
TEXT
——————————————————————————–
oracle
java
spring
hibernate
hibernate
SQL> insert into t_evan values(‘added’);
1 row created.
SQL> commit;
Commit complete.
SQL> conn / as sysdba
Connected.
SQL> shutdown immediate
ORA-00210: cannot open the specified control file
ORA-00202: control file: ‘/oracle/10g/oracle/product/10.2.0/oradata/oralife/control01.ctl’
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SQL> shutdown abort
ORACLE instance shut down.
–alter_oralife.log出现这样的信息:
Mon Aug 1 23:13:51 2011
ORA-00202: control file: ‘/oracle/10g/oracle/product/10.2.0/oradata/oralife/control01.ctl’
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
–拷贝控制文件到目标路径
SQL>ho cp /oracle/10g/oracle/bakup/database/oralife.ctl /oracle/10g/oracle/product/10.2.0/oradata/oralife/control01.ctl
SQL> alter system set control_files=’/oracle/10g/oracle/product/10.2.0/oradata/oralife/control01.ctl’ scope = spfile; –修改control_files参数,,指定可用的控制文件
System altered.
SQL> startup force mount
ORACLE instance started.
Total System Global Area 528482304 bytes
Fixed Size 1220360 bytes
Variable Size 138412280 bytes
Database Buffers 381681664 bytes
Redo Buffers7168000 bytes
Database mounted.
–生成trace文件
SQL> alter database backup controlfile to trace noresetlogs;
Database altered.
SELECT c.VALUE || ‘/’ || d.instance_name || ‘_ora_’ || a.spid || ‘.trc’ TRACE
FROM v$process a, v$session b, v$parameter c, v$instance d
WHERE a.addr = b.paddr
AND b.audsid = USERENV (‘sessionid’)
AND c.NAME = ‘user_dump_dest’;
TRACE
——————————————————————————–
/oracle/10g/oracle/product/10.2.0/db_1/admin/oralife/udump/oralife_ora_4558.trc
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
–打开trace文件,去掉注释,在shutdown状态下执行脚本,创建控制文件
–用evan登录验证数据
SQL> conn evan/evan
Connected.
SQL> select * from t_evan;
TEXT
——————————————————————————–
oracle
java
spring
hibernate
hibernate
added
6 rows selected.
可见数据没有丢失。
SQL> select name from v$controlfile;
NAME
——————————————————————————–
/oracle/10g/oracle/product/10.2.0/oradata/oralife/control01.ctl
这时应该重建多个控制文件。
如何做?