oracle用户、表空间操作常用命令

创建表空间:

 

create tablespace tablespace_name datafile '/dbf/data.dbf' size 1000M autoextend on next 100M;

创建用户并指定默认表空间:

create user cxf identified by 111111 default tablespace tablespace_name ;

赋予用户权限:

grant connect,resource,dba to cxf;

扩展表空间:

ALTER TABLESPACE tablespace_name ADD DATAFILE '/dbf/data2.DBF' SIZE 32767M;

查看用户和默认表空间的关系:

select username,default_tablespace from dba_users;

修改用户密码:

alter user 用户名 identified by 新密码;

查看剩余表空间大小:

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

查看表空间使用情况:

SELECT a.tablespace_name "表空间名称",

total / (1024 * 1024) "表空间大小(M)",

free / (1024 * 1024) "表空间剩余大小(M)",

(total - free) / (1024 * 1024 ) "表空间使用大小(M)",

total / (1024 * 1024 * 1024) "表空间大小(G)",

free / (1024 * 1024 * 1024) "表空间剩余大小(G)",

(total - free) / (1024 * 1024 * 1024) "表空间使用大小(G)",

round((total - free) / total, 4) * 100 "使用率 %"

FROM (SELECT tablespace_name, SUM(bytes) free

FROM dba_free_space

GROUP BY tablespace_name) a,

(SELECT tablespace_name, SUM(bytes) total

FROM dba_data_files

GROUP BY tablespace_name) b

WHERE a.tablespace_name = b.tablespace_name

查看表空间物理文件的名称及大小

SELECT tablespace_name,

file_id,

file_name,

round(bytes / (1024 * 1024), 0) total_space

FROM dba_data_files

ORDER BY tablespace_name;

写在最后

写文章目的就是交流分享,如有问题还请指正,本人邮箱784482906@qq.com

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

秃了也弱了。

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值