通过SQL管理表空间、用户、授权
Sql代码
–创建表空间
CREATE TABLESPACE CRMDB
DATAFILE '/opt/oracle/app/oradata/testdb/crm.dbf' SIZE 500M
AUTOEXTEND ON NEXT 100M;
–创建用户
create user CRM identified by password default tablespace CRMDB;
–给用户赋权限
grant dba to CRM;
—删除用户及数据
drop user CRM cascade;
–修改用户密码
alter user sys identified by system;
–查看表空间使用情况
select a.tablespace_name,
a.bytes / 1024 / 1024 "Sum MB",
(a.bytes – b.bytes) / 1024 / 1024 "used MB",
b.bytes / 1024 / 1024 "free MB",
round(((a.bytes – b.bytes) / a.bytes) oracle账号* 100, 2) "percent_used"
from (select tablespace_name, sum(bytes) bytes
from dba_data_files
group by tablespace_name) a,
(select tablespace_name, sum(bytes) bytes, max(bytes) largest
from dba_free_space
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name
order by ((a.bytes – b.bytes) / a.bytes) desc
–查看表空间文件地址
select name from v$datafile;