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
總結
以上是生活随笔為你收集整理的oracle用户、表空间操作常用命令的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle表空间最大30G?如果一张表
- 下一篇: 一次作死尝试:将自己的linux用rm