Oracle数据库常用操作脚本  _MySQL, Oracle及数据库讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  MySQL, Oracle及数据库讨论区 »
总帖数
2
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 2428 | 回复: 1   主题: Oracle数据库常用操作脚本          下一篇 
solo9867
注册用户
等级:新兵
经验:61
发帖:71
精华:0
注册:2011-12-15
状态:离线
发送短消息息给solo9867 加好友    发送短消息息给solo9867 发消息
发表于: IP:您无权察看 2015-9-17 17:38:15 | [全部帖] [楼主帖] 楼主

获取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;

--转自北京联动北方科技有限公司



赞(0)    操作        顶端 
联动大白
注册用户
等级:列兵
经验:91
发帖:0
精华:0
注册:2015-5-27
状态:离线
发送短消息息给联动大白 加好友    发送短消息息给联动大白 发消息
发表于: IP:您无权察看 2019-7-31 0:30:00 | [全部帖] [楼主帖] 2  楼

为了方便大家阅读,我对文章中错误号来解释一下吧!

Error Id: ORA-28000

Title: the account is locked

Description:

the account is locked

Action:

Wait for PASSWORD_LOCK_TIME or contact DBA

Cause:

The user has entered wrong password consequently for maximum number of times specified by the user’s profile parameter FAILED_LOGIN_ATTEMPTS, or the DBA has locked the account


也许你已明白,但对一个人有用也是我存在的理由!^_^ By:持之以恒的大白

-- 来自: 北京联动北方科技有限公司



赞(0)    操作        顶端 
总帖数
2
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论