获取Oracle 日志文件大小
select sum(blocks*block_size)/1024/1024/1024 as filesize from v$archived_log where name is not null and completion_time > to_date('2012-08-06 00:00:00','yyyy-mm-dd hh24:mi:ss') --5737
select
sum(bytes/1024/1024/1024) as filesize
from dba_data_files
union
select sum(bytes/1024/1024/1024) as filesize
from dba_temp_files
select
b.file_name as filename,--'物理文件名',
b.tablespace_name as tablespace,--'表空间',
b.bytes/1024/1024/1024 as filesize,--'大小M',
(b.bytes-sum(nvl(a.bytes,0)))/1024/1024/1024 as usedsize,--'已使用M',
substr((b.bytes-sum(nvl(a.bytes,0)))/(b.bytes)*100,1,5) '%' as usage-- '利用率'
from dba_free_space a,dba_data_files b
where a.file_id=b.file_id
group by b.tablespace_name,b.file_name,b.bytes
order by b.tablespace_name
Select Tablespace_Name,Sum(bytes)/1024/1024/1024 From Dba_Segments Group By Tablespace_Name
SELECT tablespace_name ,sum(blocks*8192/1000000) FROM dba_free_space GROUP BY tablespace_name;
Select Segment_Name,Sum(bytes)/1024/1024/1024 From User_Extents Group By Segment_Name
order by Sum(bytes)/1024/1024 desc
select
b.file_name as filename,--'物理文件名',
b.tablespace_name as tablespace,--'表空间',
b.bytes/1024/1024/1024 as filesize,--'大小M',
(b.bytes-sum(nvl(a.bytes,0)))/1024/1024/1024 as usedsize,--'已使用M',
substr((b.bytes-sum(nvl(a.bytes,0)))/(b.bytes)*100,1,5) '%' as usage-- '利用率'
from dba_free_space a,dba_data_files b
where a.file_id=b.file_id
group by b.tablespace_name,b.file_name,b.bytes
order by b.tablespace_name
表空间利用率
select a.tablespace_name,a.bytes/1024/1024/1024 "Sum GB",(a.bytes-b.bytes)/1024/1024/1024 "used GB",b.bytes/1024/1024/1024 "free GB",round(((a.bytes-b.bytes)/a.bytes)*100,2) '%' "percent_used"
from
(select tablespace_name,sum(bytes) bytes from dba_data_files group by tablespace_name) a,
(select tablespace_name,sum(bytes) bytes,max(bytes) largest from dba_free_space group by tablespace_name) b
where a.tablespace_name=b.tablespace_name
order by ((a.bytes-b.bytes)/a.bytes) desc
select sum(blocks * block_size) / 1024 / 1024 / 1024 as filesize
from v$archived_log
where name is not null
union
select sum(bytes / 1024 / 1024 / 1024) as filesize
from dba_data_files
union
select sum(bytes / 1024 / 1024 / 1024) as filesize from dba_temp_files
union
select sum(filesize) as filesize
from(
--log file size
select sum(blocks * block_size) / 1024 / 1024 / 1024 as filesize
from v$archived_log
where name is not null
union
--data file size
select sum(bytes / 1024 / 1024 / 1024) as filesize
from dba_data_files
union
--temp file size
select sum(bytes / 1024 / 1024 / 1024) as filesize from dba_temp_files
)
select 'ArichiveLog' as FileType, sum(blocks * block_size) / 1024 / 1024 / 1024 as FileSize from v$archived_log where name is not null
union
select 'DataFile' as FileType,sum(bytes / 1024 / 1024 / 1024) as FileSize from dba_data_files
union
select 'TempFile' as FileType,sum(bytes / 1024 / 1024 / 1024) as FileSize from dba_temp_files
union
select 'Total' as FileType,sum(filesize) as FileSize from
(select sum(blocks * block_size) / 1024 / 1024 / 1024 as filesize from v$archived_log where name is not null
union
select sum(bytes / 1024 / 1024 / 1024) as filesize from dba_data_files
union
select sum(bytes / 1024 / 1024 / 1024) as filesize from dba_temp_files)
select sum(blocks * block_size) / 1024 / 1024 / 1024 as filesize from v$archived_log where name is not null
union
select sum(bytes / 1024 / 1024 / 1024) as filesize from dba_data_files
union
select sum(bytes / 1024 / 1024 / 1024) as filesize from dba_temp_files
union
select sum(filesize) as filesize
from(select sum(blocks * block_size) / 1024 / 1024 / 1024 as filesize from v$archived_log where name is not null
union select sum(bytes / 1024 / 1024 / 1024) as filesize
from dba_data_files
union
select sum(bytes / 1024 / 1024 / 1024) as filesize from dba_temp_files)
数据库密码过期管理
1. 查看用户密码的有效期设置(一般默认的配置文件是DEFAULT)
SQL > SELECT * FROM dba_profiles WHERE profile='DEFAULT' AND resource_name='PASSWORD_LIFE_TIME'
2. 将密码有效期由默认的180天修改成“无限制”,修改之后不需要重启动数据库,会立即生效
SQL > Alter PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
3. 帐户再改一次密码
SQL > alter user ink identified by <原来的密码> ----不用换新密码
4. 使用修改后的用户登录,如果报“ORA-28000:用户已被锁”,解锁
SQL > alter user db_user account unlock;
SQL > commit;
--转自