tablespace

select * from
(select file_name,blocks,tablespace_name from dba_data_files ) allspace
left join
(select tablespace_name
,file_id
,count(*) "pieces"
,max(blocks) "MAXIMUM"
,min(blocks) "MINIMUM"
,avg(blocks) "AVERAGE"
,sum(blocks) "TOTAL"
,sum(bytes) "free"
from dba_free_space
group by
tablespace_name,file_id) freespace
on allspace.tablespace_name = freespace.tablespace_name


select USERNAME,DEFAULT_TABLESPACE from dba_users where default_tablespace = 'USERS'


select tablespace_name
,sum(bytes) free_space
from dba_free_space
group by tablespace_name


select * from tabs where tablespace_name!='SYSTEM'

select * from user_tables

select * From all_objects where object_type='TABLE' AND OWNER='SYS'


create or replace procedure grantTo(privilege in varchar2, owner in varchar2, toWho in varchar2) is

type table_name_type is table of all_tables.table_name%type
index by binary_integer;
table_name table_name_type;
sSqlStr varchar2(300);

begin
DBMS_OUTPUT.PUT_LINE('owner:' || owner);
table_name.delete;
sSqlStr := 'SELECT table_name FROM ALL_TABLES WHERE owner = : owner';
DBMS_OUTPUT.PUT_LINE('sSqlStr:' || sSqlStr);

Execute Immediate sSqlStr bulk collect into table_name using owner;

DBMS_OUTPUT.PUT_LINE('table_name.COUNT:' ||table_name.COUNT);
for i in table_name.first..table_name.last loop
sSqlStr := 'grant ' || privilege || ' on ' || owner || '.' || table_name(i) || ' to ' || toWho;
Execute Immediate sSqlStr;
end loop;

DBMS_OUTPUT.PUT_LINE('finished');

end grantTo;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值