oracle创建表空间和用户

–1.创建表空间
create tablespace NNC_DATA01 datafile’C:\orcldata\NNC_DATA01.DBF’ size 16000m autoextend on next 2048m;

–为表空间添加数据文件
ALTER TABLESPACE NNC_DATA01 ADD DATAFILE
‘C:\orcldata\NNC_DATA01_1.DBF’ SIZE 4096M;

–数据文件datafile设置为自动扩展大小
alter database datafile ‘C:\ORCLDATA\NNC_DATA01_1.DBF’ autoextend on;
–查看表空间
select tablespace_name,file_name,autoextensible from dba_data_files where tablespace_name = ‘NNC_DATA01’;

–删除表空间及数据文件
DROP TABLESPACE mes INCLUDING CONTENTS AND DATAFILES;

–表空间使用率查询
select
b.file_id 文件ID号,
b.tablespace_name 表空间名,
b.bytes/1024/1024||’M’字节数,
(b.bytes-sum(nvl(a.bytes,0)))/1024/1024||’M’ 已使用,
sum(nvl(a.bytes,0))/1024/1024||’M’ 剩余空间,
100 - sum(nvl(a.bytes,0))/(b.bytes)*100 占用百分比
from dba_free_space a,dba_data_files b
where a.file_id=b.file_id
group by b.tablespace_name,b.file_id,b.bytes
order by b.file_id;

–2.建用户
create user mes1017 identified by mes1017
default tablespace NNC_DATA01;
–无法删除当前连接用户
select username,sid,serial# from v$session where username = ‘MES1017’;
alter system kill session’12,1932’;

–3.赋权

grant dba,connect,resource to mes1017;

你可能感兴趣的:(oracle,oracle)