oracle 8i系统检查

oracle 8i系统检查

set echo on

spool d:\bk\1.txt

select sysdate from dual;

--版本信息

select * from v$version;

--安装的产品

col PARAMETER for a50;

col value for a10;

select * from v$option order by 2;

--用户信息

set linesize 100

set pagesize 100

COL USERNAME FOR A18

COL PASSWORD FOR A18

COL DEFAULT_TABLESPACE FOR A18

COL PROFILE FOR A18

col account_status for a18

SELECT USERNAME,PASSWORD,DEFAULT_TABLESPACE,PROFILE,account_status

FROM DBA_USERS ORDER BY 5,3;

--日志文件

col MEMBERS for 9;

SELECT * FROM V$LOG;

SELECT * FROM V$LOGFILE;

--归档信息,目录,格式,归档进程

col DEST_NAME for a25

col DESTINATION for a60

col value for a20

select DESTINATION from v$archive_dest where DESTINATION is not null;

select value from v$parameter where name='log_archive_format';

select * from v$archive_processes where status='ACTIVE';

col value clear

--数据文件基本信息

SELECT TABLESPACE_NAME,FILE_NAME,TRUNC(BYTES/1024/1024) MB

FROM DBA_data_files ORDER BY TABLESPACE_NAME;

--数据文件的可否自动扩展,如果可以扩展每次增加的块数

select FILE_NAME,STATUS,AUTOEXTENSIBLE,round(MAXBYTES/1024/1024/1024) gb,

INCREMENT_BY "每次增加块数"

from dba_data_files

order by 3;

--表空间的基本信息

select TABLESPACE_NAME,STATUS,CONTENTS,EXTENT_MANAGEMENT,

ALLOCATION_TYPE

from dba_tablespaces

order by 3;

--表空间的总容量和空闲空间,表空间的碎片个数和最大的碎片

select t.tablespace_name,TOTAL_MB-FREE_MB userd_mb,FREE_MB,TOTAL_MB,number_space,max_space

from

(SELECT TABLESPACE_NAME,TRUNC(SUM(BYTES)/1024/1024) TOTAL_MB

FROM DBA_data_files

GROUP BY TABLESPACE_NAME) t,

(SELECT TABLESPACE_NAME,TRUNC(SUM(BYTES)/1024/1024) FREE_MB,

count(*) number_space,round(max(bytes)/1024/1024) max_space

FROM DBA_FREE_SPACE

GROUP BY TABLESPACE_NAME) f

where t.tablespace_name=f.tablespace_name

order by number_space desc;

--数据文件的碎片个数和最大的碎片

col name for a40

select file_name,TOTAL_MB-FREE_MB userd_mb,FREE_MB,TOTAL_MB,number_space,max_space

from

(SELECT file_id,file_name,TRUNC(SUM(BYTES)/1024/1024) TOTAL_MB

FROM DBA_data_files

GROUP BY file_id,file_name) t,

(SELECT file_id,TRUNC(SUM(BYTES)/1024/1024) FREE_MB,

count(*) number_space,trunc(max(bytes)/1024/1024) max_space

FROM DBA_FREE_SPACE group by file_id ) f

where f.file_id=t.file_id

order by number_space desc;

--控制文件

col type for a25

col name for a42

select * from v$controlfile;

select * from v$controlfile_record_section;

col type clear

--临时表空间和临时文件

select * from v$tempfile;

--分区表的信息

SELECT owner,TABLE_NAME,PARTITIONING_TYPE, SUBPARTITIONING_TYPE,PARTITION_COUNT

FROM DBA_PART_TABLES

where owner not in('SYSTEM','SH');

--找到大的段

col SEGMENT_NAME for a30;

col SEGMENT_type for a20;

select OWNER,SEGMENT_NAME,SEGMENT_TYPE,TABLESPACE_NAME,BLOCKS,EXTENTS

from dba_segments

where EXTENTS>50 or BLOCKS>10000

order by BLOCKS desc;

--索引信息,找到无效的索引

col owner for a12;

col tablespace_name for a12;

select index_name,owner,table_name,tablespace_name,status

from dba_indexes

where owner not in ('SYS','SYSTEM')

and status != 'VALID'

and tablespace_name is not null;

--排序段信息

select * from V$sort_usage;

--内存信息

col name for a30;

col value clear;

select * from v$sga;

select gethitratio*100

from v$librarycache

where namespace = 'SQL AREA';

select * from V$SHARED_POOL_RESERVED;

SELECT (1 - (phy.value -lob.value -dir.value)/ses.value)*100 "CACHE HIT RATIO"

FROM vsysstat ses, vsysstat lob,

vsysstat dir, vsysstat phy

WHERE ses.name = 'session logical reads'

AND dir.name = 'physical reads direct'

AND lob.name = 'physical reads direct (lob)'

AND phy.name = 'physical reads';

--综合统计

col value clear

col name for a53

select * from v$sysstat where value<>0;

--等待事件

select * from v$system_event;

select * from v$session_wait

where event not in

('rdbms ipc message','null event','smon timer','pmon timer','wakeup time manager');

--回退信息

select SEGMENT_NAME,INITIAL_EXTENT,NEXT_EXTENT,MIN_EXTENTS,MAX_EXTENTS,STATUS

from dba_rollback_segs;

select USN "编号",EXTENTS "现有范围",RSSIZE "现有大小" ,HWMSIZE "最大值",

SHRINKS "回缩次数",AVESHRINK "平均回缩大小",EXTENDS "扩展次数" from v$rollstat;

--锁的信息

col sid for 999

col LMODE for 9

col REQUEST for 9

col BLOCK for 9

col type clear

select * from v$lock;

--并行查询

col value clear;

col STATISTIC for a30;

SELECT * FROM V$PQ_SYSSTAT;

--参数文件

col name for a40

col value for a50

select name,value from v$parameter where value is not null and value<>'0';

--后台进程

col name for a15;

select paddr, NAME, DESCRIPTION from v$bgprocess where paddr<>'00';

--总进程信息

col PROGRAM for a30

select ADDR,BACKGROUND ,PROGRAM,TERMINAL,USERNAME

from v$process order by 2 ;

spool off

相关推荐
软茸兔3 小时前
笔记:一次oracle 集群日志维护
数据库·笔记·oracle
东方佑4 小时前
pandas df 如何 输出数据到 sqlite3
oracle·sqlite·pandas
ROCKY_81710 小时前
Mysql复习(二)
数据库·mysql·oracle
水根LP4912 小时前
linux系统上SQLPLUS的重“大”发现
数据库·oracle
littlegirll14 小时前
一个从oracle使用spool导出数据到kadb的脚本
数据库·oracle
geovindu14 小时前
CSharp: Oracle Stored Procedure query table
数据库·oracle·c#·.net
core51218 小时前
flink cdc各种数据库 jar下载地址
mysql·oracle·flink·jar·oceanbase·cdc
秀儿y1 天前
Redis-十大数据类型
数据库·redis·缓存·oracle
Ahern_1 天前
Oracle 普通表至分区表的分区交换
大数据·数据库·sql·oracle
2401_857600951 天前
技术与教育的融合:构建现代成绩管理系统
数据库·oracle