oracle用户、表空间操作常用命令
創(chuàng)建表空間:
?
create tablespace tablespace_name datafile '/dbf/data.dbf' size 1000M autoextend on next 100M;
創(chuàng)建用戶并指定默認(rèn)表空間:
create user cxf identified by 111111 default tablespace tablespace_name ;
賦予用戶權(quán)限:
grant connect,resource,dba to cxf;
擴(kuò)展表空間:
ALTER TABLESPACE tablespace_name ADD DATAFILE '/dbf/data2.DBF' SIZE 32767M;
查看用戶和默認(rèn)表空間的關(guān)系:
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;
寫(xiě)在最后
寫(xiě)文章目的就是交流分享,如有問(wèn)題還請(qǐng)指正,本人郵箱784482906@qq.com
總結(jié)
以上是生活随笔為你收集整理的oracle用户、表空间操作常用命令的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: oracle表空间最大30G?如果一张表
- 下一篇: SOA和微服务之间的区别(应用和数据的垂