1.用sql查数据库容量
select sum(db_size) db_size from
( (select tablespace_name,sum(nvl(bytes,0))/1024/1024 db_size from dba_free_space group by tablespace_name )
union all (select tablespace_name,sum(user_bytes)/1024/1024
db_size from dba_data_files group by
tablespace_name)
union all
(select tablespace_name ,sum(user_bytes)/1024/1024 db_size from dba_temp_files group by tablespace_name)
) tmp;
中间遇到个问题:
1.在sqlplu 下报了错误,如图,但是放到sqldeveloper却执行正常
2.我用的edit命令为什么会生成的是@orcletest.sql呢
3另外在三个子查询中加别名 的话 plsqldeveloper会报错:缺失’)‘;
第二种方法
select sum(size_) size_ from
( select sum(bytes)/1024/1024 size_ from dba_data_files union select sum(bytes)/1024/1024 size_ from dba_temp_files )
问题:本来以为这两个方法都是正确的,但是最后得出了不同的结果? 不知道哪个是正确的呢?为什么?
2.计算某个用户下对象的总大小(promanager 用户)
select sum(bytes)/1024/1024 obj_size from ( SELECT * FROM user_segments
where segment_name in (select object_name from all_objects where all_objects.owner='PROMANAGER') )
3.查询某个表空间的大小以及这个表空间下对象的大小
select 'SIZE_TABELSPACE' NAME_, sum(user_bytes)/1024/1024 SIZE_ from dba_data_files where tablespace_name='USERS' UNION ALL select 'SIZE_OBJECT' NAME_, sum(nvl(bytes,0))/1024/1024 SIZE_ from user_segments where tablespace_name='USERS'
问题:用sys登录的时候发现下边对象的大小是空的,sys在users表空间没有对象吗?
4.查找alert_orcl.log 中的error
Mon Sep 03 07:03:13 2012 Errors in file d:\oracle\product\10.2.0\admin\orcl\udump\orcl_ora_1716.trc: ORA-00313: ??????? 1 (???? 1) ??? ORA-00312: ???? 1 ?? 1: 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01.LOG' ORA-27041: ?????? OSD-04002: 无法打开文件 O/S-Error: (OS 2) 系统找不到指定的文件。
----------------------------------------------------------------------------------------------------------
下边是根据论坛上同学的贴的方法操作的
(1) show parameter dump
(2)create or replace directory alert as d:/oracle/product/oracle/admin/bdump'
(3) create table alert 1 (log varchar2(1000)) 2 organization external 3 (type oracle_loader 4 default directory alert 5 access parameters 6 (records delimited by newline) 7 location ('alert_ORCL.log')) 8 reject limit unlimited;
-------1. edit命令后(我是指没有加文件名参数的情况)在文本里边写了代码如何调用?
------2. 能稍微解释一下创建表的这部分吗?
organization external (type oracle_loader default directory alert access parameters (records delimited by newline) location ('alert_ORCL.log')) reject limit unlimited;
(4)select * from alert where log like '%ORA-%'
5.在官网找v$session 和 dbms_stats