创建oracle用户,给用户授权

本文介绍如何在Oracle数据库中查询所有表空间及其详细信息,包括总量、剩余空间等,并展示如何创建新用户并授予相应的权限。同时,还提供了查询特定表空间下用户的SQL语句。

1、查询所有表空间

select dbf.tablespace_name,

dbf.totalspace "总量(M)",

dbf.totalblocks as 总块数,

dfs.freespace "剩余总量(M)",

dfs.freeblocks "剩余块数",

(dfs.freespace / dbf.totalspace) * 100 "空闲比例"

from (select t.tablespace_name,

sum(t.bytes) / 1024 / 1024 totalspace,

sum(t.blocks) totalblocks

from dba_data_files t

group by t.tablespace_name) dbf,

(select tt.tablespace_name,

sum(tt.bytes) / 1024 / 1024 freespace,

sum(tt.blocks) freeblocks

from dba_free_space tt

group by tt.tablespace_name) dfs

where trim(dbf.tablespace_name) = trim(dfs.tablespace_name);

2、查询表空间HBZF的信息(如无可用的表空间需要新建一个表空间

select t.*  from sys.dba_data_files t where t.tablespace_name ='HBZF';

3、创建新的用户

create user bthb_wjgl

  identified by "bthb_wjgl"

  default tablespace HBZF 

  profile DEFAULT

  ACCOUNT UNLOCK;

4、给用户授权

grant connect,dba to bthb_wjgl;

5、查询HBZF表空间的所有用户

select * from dba_users t where t.default_tablespace ='HBZF'

转载于:https://www.cnblogs.com/lkzp123456/p/6428198.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值