DBA - 我的学习
1. df -k 检查oracle 分区硬盘使用情况
2. 检查alert_<SID名称>.log, alert日志文件,检查是否新增错误日志
3. 检查数据文件的状态记录状态不是“online”的数据文件,并考虑是否需要做恢复。
select file_name from dba_data_files where status='OFFLINE'
4.
检查表空间的使用情况
SELECT tablespace_name, max_m, count_blocksfree_blk_cnt, sum_free_m,to_char(100*sum_free_m/sum_m, '99.99') || '%' AS pct_free
FROM ( SELECT tablespace_name,sum(bytes)/1024/1024 AS sum_m FROM dba_data_files GROUP BY tablespace_name),
( SELECT tablespace_name AS fs_ts_name, max(bytes)/1024/1024 AS max_m, count(blocks) AS count_blocks, sum(bytes/1024/1024) AS sum_free_m FROM dba_free_space GROUP BY tablespace_name )
WHERE tablespace_name = fs_ts_name
order by pct_free
5.
检查剩余表空间
SELECT tablespace_name, sum ( blocks ) as free_blk ,
trunc ( sum ( bytes ) /(1024*1024) ) as free_m,
max ( bytes ) / (1024) as big_chunk_k, count (*) as num_chunks
FROM dba_free_space GROUP BY tablespace_name;
6.
检查无效的数据库对象
SELECT owner, object_name, object_type FROM dba_objects
WHERE status='INVALID‘
7.
检查不起作用的约束
SELECT owner, constraint_name, table_name,
constraint_type, status
FROM dba_constraints
WHERE
status = 'DISABLED' AND constraint_type = 'P' ;
8.
检查无效的trigger
SELECT owner, trigger_name, table_name, status
FROM dba_triggers
WHERE status = 'DISABLED'
9.
DBA查询表,约束,字段,表空间,数据文件
DBA_TABLES,
DBA_INDEXES,
DBA_TAB_COLUMNS,
DBA_CONSTRAINTS,
DBA_TABLESPACES,
DBA_DATA_FILES
10.
控制文件信息
show parameter CONTROL_FILES;
select * from V$CONTROLFILE;
11.
表空间分类
12.
CONNECT角色: --是授予最终用户的典型权利,最基本的
CREATE SESSION --建立会话
RESOURCE角色: --是授予开发人员的
CREATE CLUSTER --建立聚簇
CREATE PROCEDURE --建立过程
CREATE SEQUENCE --建立序列
CREATE TABLE --建表
CREATE TRIGGER --建立触发器
CREATE TYPE --建立类型
CREATE OPERATOR --创建操作者
CREATE INDEXTYPE --创建索引类型
GRANT xxxx xxxxx to username;
13. 因为数据文件丢失,导致实例启动失败。
alter database datafile ‘xxxx.dbf‘ offline drop;
alter database open;
即可