欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

ORACLE关于日志文件基本操作

程序员文章站 2022-07-05 08:42:36
1.查询系统使用的是哪一组日志文件:SELECT * FROM V$LOG; 2.查询正在使用的组所对应的日志文件:SELECT * FROM V$LOGFILE; 3.强制日志切换:ALTER SYSTEM SWITCH LOGFILE; 4.查询历史日志:SELECT * FROM V$LOG_ ......

1.查询系统使用的是哪一组日志文件:
select * from v$log;

2.查询正在使用的组所对应的日志文件:
select * from v$logfile;

3.强制日志切换:
alter system switch logfile;

4.查询历史日志:
select * from v$log_history;

5.查询日志的归档模式:
select dbid,name,created,log_mode from v$database;

6.查询归档日志的信息:
select recid,stamp,thread#,sequence#,name from v$archived_log;

7.增加与删除日志文件组
alter database add logfile group 1 ('/home1/oracle/oradata/ora8i/log1a.log'),'/home2/oracle/oradata/ora8i/log1b.log') size 100m;

alter database drop logfile group 1;

8.增加与删除日志成员
alter database add logfile member '/home1/oracle/oradata/ora8i/log1a.log' to group 1,'/home1/oracle/oradata/ora8i/log2a.log' to group 2;

alter database drop logfile member '/home1/oracle/oradata/ora8i/log1a.log' ;

9.日志文件移动
alter database rename file '/home1/oracle/oradata/ora8i/log1a.log' to '/home2/oracle/oradata/ora8i/log1a.log';
执行该命令之前必须保证该日志文件物理上已经移动到新目录

10.清除日志文件
alter database clear logfile '/home1/oracle/oradata/ora8i/log1a.log';
该命令用于不能用删除组及组成员命令删除日志时使用

8.查看归档日志占用空间:
select space_limit/1024/1024/1024 as "quota_g",space_used/1024/1024 as "used_m",space_used/space_limit*100 "used_%",space_reclaimable as reclaimable,number_of_files as files from v$recovery_file_dest ;

9.修改归档日志空间大小
alter system set db_recovery_file_dest_size=40g;

10.查看归档日志列表
rman> list archivelog all;
删除归档日志
rman> delete archivelog until time 'sysdate-1' ;
双机下也可以用
delete obsolete;
crosscheck archivelog all;
delete expired archivelog all;

11. 用list expired看看是否有失效的archive log,证明没有失效的archive log:
rman> list expired archivelog all;